public MeasurementSymmetryLine(ROI roiOne, ROI roiTwo, MeasureAssistant mAssist)
     : base(null, mAssist)
 {
     var lineF = new MeasurementEdge(roiOne, mAssist);
     var lineS = new MeasurementEdge(roiTwo, mAssist);
     initialize(lineF.GetViewModel(), lineS.GetViewModel(), mAssist);
 }
Exemple #2
0
        /// <summary>
        /// Paints all objects from the ROIList into the HALCON window
        /// </summary>
        /// <param name="window">HALCON window</param>
        public void paintData(HalconDotNet.HWindow window)
        {
            window.SetDraw("margin");
            window.SetLineWidth(1);

            if (ROIList.Count > 0)
            {
                //window.SetDraw("margin");

                for (int i = 0; i < ROIList.Count; i++)
                {
                    ROI roi = (ROI)ROIList[i];
                    window.SetLineStyle(roi.flagLineStyle);
                    if (roi.error)
                    {
                        window.SetColor(errorCol);
                    }
                    else
                    {
                        window.SetColor(inactiveCol);
                    }
                    roi.draw(window);
                }

                if (ActiveROIidx != -1)
                {
                    window.SetColor(activeCol);
                    window.SetLineStyle(((ROI)ROIList[ActiveROIidx]).flagLineStyle);
                    ((ROI)ROIList[ActiveROIidx]).draw(window);

                    window.SetColor(activeHdlCol);
                    ((ROI)ROIList[ActiveROIidx]).displayActive(window);
                }
            }
        }
 /// <summary>
 /// Creates a measurement object for the provided ROI instance.
 /// </summary>
 /// <param name="roi">ROI instance</param>
 /// <param name="mAssist">Reference to controller class</param>
 public MeasurementEdge(ROI roi, MeasureAssistant mAssist)
     : base(roi, mAssist)
 {
     mResult = new EdgeResult();
     mResultWorld = new EdgeResult();
     UpdateMeasure();
 }
Exemple #4
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);
            }
        }
 public void showROIShape(ROI r)
 {
     ROIList.Add(r);
     roiMode      = null;
     activeROIidx = ROIList.Count - 1;
     viewController.repaint();
 }
Exemple #6
0
        public 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 = -3;
                return(null);
            }
        }
 /// <summary>
 /// Creates and initializes a measure object based on information the ROI object
 /// about the ROI.
 /// </summary>
 /// <param name="roi">ROI instance</param>
 /// <param name="mAssist">Reference to controller class</param>
 public Measurement(ROI roi, MeasureAssistant mAssist)
 {
     mMeasAssist = mAssist;
     mEdgeXLD = new HXLDCont();
     mMeasureRegion = new HRegion();
     initROI(roi);
 }
 public MeasurementFitLine(ROI roi, MeasureAssistant mAssist)
     : base(roi, mAssist)
 {
     mResult = new FitLineResult();
     _cameraOut = new HTuple();
     UpdateMeasure();
 }
 /// <summary>
 /// CreateROIContour, 直接建立 ROI Contour 在 window 上
 /// </summary>
 /// <param name="contour"></param>
 public void CreateROIContour(ROI contour)
 {
     ROIList.Add(contour);
     activeROIidx = ROIList.Count - 1;
     viewController.repaint();
     NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
 }
 /// <summary>
 /// Clears all variables managing ROI objects
 /// </summary>
 public void reset()
 {
     ROIList.Clear();
     activeROIidx = -1;
     ModelROI     = null;
     roiMode      = null;
     NotifyRCObserver(EVENT_DELETED_ALL_ROIS);
 }
        private void doNormalROIAction(double imgX, double imgY)
        {
            roiMode.createROI(imgX, imgY);
            ROIList.Add(roiMode);
            roiMode      = null;
            activeROIidx = ROIList.Count - 1;
            viewController.repaint();

            NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
        }
        /// <summary>
        /// 將 ROI 建立在 Windows 上,並觸發 Update
        /// </summary>
        /// <param name="contour"></param>
        public void ReloadROI(ROI contour)
        {
            ROIList.Add(contour);
            activeROIidx = ROIList.Count - 1;
            if (viewController != null)
            {
                viewController.repaint();
            }

            NotifyRCObserver(ROIController.EVENT_Reload_ROI);
        }
 public AutoFitPoint(ROI roi, MeasureAssistant mAssist)
     : base(roi, mAssist)
 {
     mResult = new EdgeResult();
     mResultWorld = new EdgeResult();
     if (mMeasAssist.IsCalibrationValid)
     {
         _cameraOut = HMisc.ChangeRadialDistortionCamPar("adaptive", mMeasAssist.CameraIn, 0.0);
     }
     UpdateMeasure();
 }
Exemple #14
0
 public void addROI(ROI roi)
 {
     if (roi != null)
     {
         roi.construct();
         ROIList.Add(roi);
         roiMode = null;
         viewController.repaint();
         NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
     }
 }
Exemple #15
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;
            int    idxSizeEnableROI = -1;
            double max = 10000, dist = 0;

            //double epsilon = 20.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;

                for (int i = 0; i < ROIList.Count; i++)
                {
                    if (ROIList[i] is ROIRegion)//ROIRegion例外
                    {
                        continue;
                    }
                    dist = ((ROI)ROIList[i]).distToClosestHandle(imgX, imgY);
                    if ((dist <= max) && (dist < epsilon))
                    {
                        max    = dist;
                        idxROI = i;
                        if (((ROI)ROIList[i]).SizeEnable == true)
                        {
                            idxSizeEnableROI = i;
                        }
                    }
                }                                                        //end of for
                if (idxROI != idxSizeEnableROI && idxSizeEnableROI >= 0) //优先SizeEnable的
                {
                    idxROI = idxSizeEnableROI;
                }
                if (idxROI >= 0)
                {
                    activeROIidx = idxROI;
                    NotifyRCObserver(ROIController.EVENT_ACTIVATED_ROI);
                }

                viewController.repaint();
            }
            return(activeROIidx);
        }
 public void SetActiveROI(ROI r)
 {
     for (int roiIndex = 0; roiIndex < ROIList.Count; roiIndex++)
     {
         var roi = (ROI)ROIList[roiIndex];
         if (roi.ID == r.ID)
         {
             setActiveROIIdx(roiIndex);
             break;
         }
     }
 }
Exemple #17
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);
     ////if (center != null)
     ////{
     ////    for (int i = 1; i < center.GetLength(1); i++)
     ////    {
     ////        roiMode.createROI(center[i].X, center[i].Y);
     ////        ROIList.Add(roiMode);
     ////    }
     ////}
 }
        /// <summary>
        /// Creates and initializes a measure object based on information the ROI object
        /// about the ROI.
        /// </summary>
        /// <param name="roi">ROI instance</param>
        /// <param name="mAssist">Reference to controller class</param>
        public Measurement(ROI roi, MeasureAssistant mAssist)
        {
            mRoi = roi;
            mMeasAssist = mAssist;
            mROICoord = mRoi.getModelData();
            mEdgeXLD = new HXLDCont();
            mMeasureRegion = new HRegion();

            if (mRoi is ROICircularArc)
                mROIType = ROI.ROI_TYPE_CIRCLEARC;
            else
                mROIType = ROI.ROI_TYPE_LINE;
        }
Exemple #19
0
        public void CopyROIShape(ROI r, double midX, double midY)
        {
            if (r != null)
            {
                r.SetCenterIndex();
                r.moveByHandle(midX, midY);
                ROIList.Add(r);
                r            = null;
                activeROIidx = ROIList.Count - 1;
                viewController.repaint();

                NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
            }
        }
Exemple #20
0
        public void createExistingROI(HTuple RoiParameters)
        {
            if (roiMode != null)             //either a new ROI object is created
            {
                roiMode.createROI(RoiParameters);
                ROIList.Add(roiMode);
                roiMode      = null;
                activeROIidx = ROIList.Count - 1;
                viewController.repaint();


                NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
            }
        }
Exemple #21
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);

                //添加自己想显示的ROI
                ////userROI.createROI(1000,500);
                ////ROIList.Add(userROI);


                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;

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

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

                viewController.repaint();
            }
            return(activeROIidx);
        }
Exemple #22
0
 public void removeROIShape(ROI r)
 {
     if (r == getActiveROI())
     {
         removeActive();
     }
     else
     {
         ROIList.Remove(r);
         //ROIList.RemoveAt(activeROIidx);
         //deletedIdx = activeROIidx;
         activeROIidx = -1;
         viewController.repaint();
         NotifyRCObserver(EVENT_DELETED_ACTROI);
     }
     GC.Collect();//垃圾回收
 }
Exemple #23
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);
            }
        }
Exemple #24
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);
            }
        }
Exemple #25
0
        /// <summary>
        /// 在指定位置生成ROI--Circle
        /// </summary>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="radius"></param>
        /// <param name="rois"></param>
        public void displayCircle(string color, double row, double col, double radius)
        {
            setROIShape(new ROICircle());

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

                NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
            }
        }
Exemple #26
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, double midX, double midY)
        {
            roiMode = r;
            roiMode.setOperatorFlag(stateROI);

            if (roiMode != null)                         //either a new ROI object is created
            {
                roiMode.createROI(midX, midY);

                ROIList.Add(roiMode);

                roiMode      = null;
                activeROIidx = ROIList.Count - 1;
                viewController.repaint();

                NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
            }
        }
        private void doContinueZoomROIAction(double imgX, double imgY, IContinueZoom smartROI)
        {
            var done = smartROI.WaitForClickPoints(imgX, imgY);

            if (smartROI.ClickedPoints == 1)
            {
                _waitForClickROI = (ROI)smartROI;
            }
            viewController.repaint();
            if (done)
            {
                ROIList.Add(smartROI);
                _waitForClickROI = null;
                roiMode          = null;
                viewController.DisableZoomContinue();
                activeROIidx = ROIList.Count - 1;
                NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
            }
        }
Exemple #28
0
        /// <summary>
        /// 在指定位置生成ROI--Circle
        /// </summary>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="radius"></param>
        /// <param name="rois"></param>
        public void genCircle(double row, double col, double radius, ref System.Collections.Generic.List <ROI> rois)
        {
            setROIShape(new ROICircle());

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

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

                NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
            }
        }
Exemple #29
0
        /// <summary>
        /// 重建模型資料
        /// </summary>
        /// <returns></returns>
        public ROI MakeROI()
        {
            ROI roi = null;

            switch (ROIType)
            {
            case ROI.ROI_TYPE_RECTANGLE2:
                roi = new ROIRectangle2();
                (roi as ROIRectangle2).MakeROI(CenterRow, CenterCol, Phi, Length, Width);
                break;

            case ROI.ROI_TYPE_CIRCLE:
                roi = new ROICircle();
                (roi as ROICircle).MakeROI(CenterRow, CenterCol, Radius);
                break;
            }
            if (roi != null)
            {
                roi.ID = this.ID;
            }
            return(roi);
        }
Exemple #30
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);
            }
        }
 /// <summary>
 /// 新增有 ROI model 的資料列
 /// </summary>
 /// <param name="roi"></param>
 /// <param name="tmpGeoDataViewModel"></param>
 private void addROIRecord(ROI roi, GeoDataGridViewModel tmpGeoDataViewModel)
 {
     _DataList.Add(tmpGeoDataViewModel);
     addTreeNode(roi, tmpGeoDataViewModel);
 }
        private void addTreeNode(ROI activeROI, GeoDataGridViewModel geoModel)
        {
            if (_TreeViewContainer != null)
            {
                var number = _DataList.Count;
                var roiNodeName = String.IsNullOrEmpty(geoModel.Name) ? String.Format("{0} {1}", number.ToString("d2"), activeROI.ROIMeasureType) : geoModel.Name;
                var roiImageKey = activeROI.ROIMeasureType.ToString();
                var index = _TreeViewContainer.Nodes.Count;
                TreeNode roiNode = new TreeNode()
                {
                    Name = geoModel.RecordID,
                    Text = roiNodeName,
                    ImageKey = roiImageKey,
                    SelectedImageKey = roiImageKey,
                    Checked = activeROI.Visiable,
                    Tag = activeROI,
                };
                if (_geoContextMenuStrip != null)
                {
                    roiNode.ContextMenuStrip = _geoContextMenuStrip;
                }

                _TreeViewContainer.Nodes.Add(roiNode);
                _TreeViewContainer.Focus();
                _TreeViewContainer.SelectedNode = roiNode;
            }
        }
 /// <summary>
 /// Factory method to create measure objects
 /// </summary>
 /// <param name="roi">Interactive ROI</param>
 /// <param name="parent">
 /// Reference to measure controller class
 /// </param>
 /// <returns>New measure object</returns>
 public static Measurement CreateMeasure(ROI roi, MeasureAssistant parent)
 {
     if (parent.mSelPair)
         return new MeasurementPair(roi, parent);
     else
         return new MeasurementEdge(roi, parent);
 }
 private void findTheNode(ROI activeROI, TreeNodeCollection treeNodeCollection)
 {
     try
     {
         foreach (TreeNode node in treeNodeCollection)
         {
             var nodeROI = node.Tag as ROI;
             var findIt = (nodeROI != null && nodeROI.ID == activeROI.ID);
             if (findIt)
             {
                 node.TreeView.SelectedNode = node;
                 node.Expand();
                 node.TreeView.Focus();
                 break;
             }
             if (!findIt)
                 findTheNode(activeROI, node.Nodes);
         }
     }
     catch (Exception ex)
     {
         Hanbo.Log.LogManager.Error(ex);
     }
 }
 /// <summary>
 /// 取得 幾何物件 Image
 /// </summary>
 /// <param name="roi"></param>
 /// <returns></returns>
 private Bitmap getGeoViewModelIcon(ROI roi)
 {
     if (roi == null) return null;
     Bitmap iconImage = null;
     var key = roi.ROIMeasureType.ToString();
     if (_ImageList.ContainsKey(key))
     {
         iconImage = _ImageList[key];
     }
     return iconImage;
 }
 public void SetActiveROI(ROI r)
 {
     for (int roiIndex = 0; roiIndex < ROIList.Count; roiIndex++)
     {
         var roi = (ROI)ROIList[roiIndex];
         if (roi.ID == r.ID)
         {
             setActiveROIIdx(roiIndex);
             break;
         }
     }
 }
        /// <summary>
        /// 組成 GeoDataViewModel
        /// <para>把 ROI 轉成GeoDataViewModel</para>
        /// </summary>
        /// <param name="roiIndex">active ROI index</param>
        /// <param name="viewModel">MeasureViewModel</param>
        /// <param name="roi">ROI</param>
        /// <returns></returns>
        private GeoDataGridViewModel transferROIToGeoDataViewModel(MeasureViewModel viewModel, ROI roi, bool isAddNew)
        {
            var number = _DataList.Count + 1;
            var measureName = number.ToString("d2") + " " + roi.ROIMeasureType;
            var exportUnit = roi.ROIMeasureType == MeasureType.Angle ? "Angle" :
                            roi.ROIMeasureType == MeasureType.Point ? "" : _ExportUnit;

            var distance = (viewModel.Distance != null && viewModel.Distance.TupleLength() > 0) ?
                        viewModel.Distance.D : 0.0;

            //圓類型, 距離為半徑 or 直徑
            var isCircleType = (viewModel.GeoType == MeasureType.PointCircle || viewModel.GeoType == MeasureType.Circle);
            distance = (isCircleType) ? distance * _circleDistanceSetting : distance;

            var curCoordinate = _refCoordinate.SingleOrDefault(p => p.ID == _currentCoordinateID);
            var curSkew = _refSkew.SingleOrDefault(p => p.ID == _currentSkewID);
            GeoDataGridViewModel geoModel = new GeoDataGridViewModel()
            {
                Icon = getGeoViewModelIcon(roi),
                Name = measureName,
                ROIID = roi.ID,
                ROIModel = roi.ToROIViewModel(),
                Col1 = (viewModel.Col1 != null && viewModel.Col1.TupleLength() > 0) ?
                        viewModel.Col1.D : -1.0,
                Row1 = (viewModel.Row1 != null && viewModel.Row1.TupleLength() > 0) ?
                        viewModel.Row1.D : -1.0,
                Distance = distance,
                WorldDistance = pixelToRealWorldValue(distance),

                Col2 = (viewModel.Col2 != null && viewModel.Col2.TupleLength() > 0) ?
                        viewModel.Col2.D : -1.0,

                Row2 = (viewModel.Row2 != null && viewModel.Row2.TupleLength() > 0) ?
                        viewModel.Row2.D : -1.0,
                Selected = false,
                Unit = exportUnit,
                GeoType = roi.ROIMeasureType,
            };
            var arcRoi = roi as SmartArc;
            if (arcRoi != null)
            {
                var roiModelData = arcRoi.getModelData();
                geoModel.StartPhi = roiModelData[3];
                geoModel.EndPhi = roiModelData[4];
            }

            if (isAddNew)
            {
                if (curCoordinate != null)
                {
                    geoModel.CoordinateID = curCoordinate.ID;
                    geoModel.CoordinateName = curCoordinate.Name;
                }
            }
            //設定參考座標值
            double refCoordinateCol, refCoordinateRow;
            getRefCoordinate(geoModel, out refCoordinateCol, out refCoordinateRow);
            geoModel.CoordinateCol = refCoordinateCol;
            geoModel.CoordinateRow = refCoordinateRow;

            //計算軸擺正
            if (curSkew != null)
            {
                geoModel.SkewID = curSkew.ID;
                geoModel.SkewName = curSkew.Name;
                geoModel.Skew = getSkew(geoModel.SkewID);
            }
            return geoModel;
        }
        private void doNormalROIAction(double imgX, double imgY)
        {
            roiMode.createROI(imgX, imgY);
            ROIList.Add(roiMode);
            roiMode = null;
            activeROIidx = ROIList.Count - 1;
            viewController.repaint();

            NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
        }
 /// <summary>
 /// CreateROIContour, �����إ� ROI Contour �b window �W
 /// </summary>
 /// <param name="contour"></param>
 public void CreateROIContour(ROI contour)
 {
     ROIList.Add(contour);
     activeROIidx = ROIList.Count - 1;
     viewController.repaint();
     NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
 }
Exemple #40
0
 public int GetROIShapeIndex(ROI r)
 {
     return(ROIList.IndexOf(r));
 }
Exemple #41
0
 public void setActiveROIShape(ROI r)
 {
     setActiveROIIdx(ROIList.IndexOf(r));
 }
        /// <summary>
        /// �N ROI �إߦb Windows �W�A��IJ�o Update
        /// </summary>
        /// <param name="contour"></param>
        public void ReloadROI(ROI contour)
        {
            ROIList.Add(contour);
            activeROIidx = ROIList.Count - 1;
            if (viewController != null)
                viewController.repaint();

            NotifyRCObserver(ROIController.EVENT_Reload_ROI);
        }
 /// <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;
 }
 private void initROI(ROI roi)
 {
     if (roi == null) return;
     mRoi = roi;
     mROICoord = mRoi.getModelData();
     switch (mRoi.ROIMeasureType)
     {
         case MeasureType.None:
             if (mRoi is ROICircularArc)
                 mROIType = ROI.ROI_TYPE_CIRCLEARC;
             else
                 mROIType = ROI.ROI_TYPE_LINE;
             break;
         case MeasureType.Point:
             mROIType = ROI.ROI_TYPE_POINT;
             break;
         case MeasureType.Line:
             mROIType = ROI.ROI_TYPE_LINE;
             break;
         case MeasureType.FitLine:
             mROIType = ROI.ROI_TYPE_LINE;
             break;
         case MeasureType.Circle:
             mROIType = ROI.ROI_TYPE_CIRCLE;
             break;
     }
     ROIMeasureType = mRoi.ROIMeasureType;
 }
 /// <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);
 }
 /// <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);
 }
 /// <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;
 }
Exemple #48
0
 public ViewROI.ROI smallestActiveROI(out List <double> data, out int index)
 {
     ViewROI.ROI roi = this._roiController.smallestActiveROI(out data, out index);
     return(roi);
 }
 private void doContinueZoomROIAction(double imgX, double imgY, IContinueZoom smartROI)
 {
     var done = smartROI.WaitForClickPoints(imgX, imgY);
     if (smartROI.ClickedPoints == 1)
     {
         _waitForClickROI = (ROI)smartROI;
     }
     viewController.repaint();
     if (done)
     {
         ROIList.Add(smartROI);
         _waitForClickROI = null;
         roiMode = null;
         viewController.DisableZoomContinue();
         activeROIidx = ROIList.Count - 1;
         NotifyRCObserver(ROIController.EVENT_CREATED_ROI);
     }
 }
        /// <summary>
        /// 新增 ViewModel or 更新 ViewModel
        /// </summary>
        /// <param name="model"></param>
        /// <param name="roi"></param>
        public void UpdateViewModel(MeasureViewModel model, ROI roi)
        {
            if (model == null || roi == null) return;

            var roiRecord = GetViewModel(roi.ID);
            var isAddNew = (roiRecord == null);
            GeoDataGridViewModel tmpROIRecord = transferROIToGeoDataViewModel(model, roi, isAddNew);
            var updateTreeNodeID = isAddNew ? tmpROIRecord.RecordID : roiRecord.RecordID;
            if (isAddNew)
            {
                addROIRecord(roi, tmpROIRecord);
            }
            else
            {
                updateROIRecord(roiRecord.RecordID, tmpROIRecord);
            }
            this.Refresh();
            setTreeNodeFocus(updateTreeNodeID);
            notifyRecordChanged(GeoDataGridViewNotifyType.UpdateData, tmpROIRecord);
        }
Exemple #51
0
 public void AddROIShape(ROI r)          //增加一个ROI到ROIlist中
 {
     ROIList.Add(r);
     activeROIidx = ROIList.Count - 1;
     viewController.repaint();
 }
 public void SetTreeViewNodeActivate(ROI activeROI)
 {
     if (_TreeViewContainer != null)
     {
         findTheNode(activeROI, _TreeViewContainer.Nodes);
     }
 }
        /// <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;

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

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

                viewController.repaint();
            }
            return activeROIidx;
        }
 /// <summary>
 /// Factory method to create measure objects
 /// </summary>
 /// <param name="roi">Interactive ROI</param>
 /// <param name="parent">
 /// Reference to measure controller class
 /// </param>
 /// <returns>New measure object</returns>
 public static Measurement CreateMeasure(ROI roi, MeasureAssistant parent)
 {
     Measurement mMeasurement = null;
     switch (roi.ROIMeasureType)
     {
         case MeasureType.Circle:
             mMeasurement = new MeasurementCircle(roi, parent);
             break;
         case MeasureType.Line:
             if (_doFitLineAlgo)
                 mMeasurement = new MeasurementFitLine(roi, parent);
             else
                 mMeasurement = new MeasurementEdge(roi, parent);
             break;
         case MeasureType.Point:
             if (roi is ViewROI.SmartROIs.SmartPoint)
             {
                 mMeasurement = new SmartMeasurements.AutoFitPoint(roi, parent);
             }
             else
             {
                 mMeasurement = new MeasurementEdge(roi, parent);
             }
             break;
         default:
             mMeasurement = new MeasurementEdge(roi, parent);
             break;
     }
     //if (parent.mSelPair)
     //	return new MeasurementPair(roi, parent);
     //else if (roi.ROIMeasureType == MeasureType.Circle)
     //{
     //	return new MeasurementCircle(roi, parent);
     //}
     //else
     //	return new MeasurementEdge(roi, parent);
     return mMeasurement;
 }
 /// <summary>
 /// Clears all variables managing ROI objects
 /// </summary>
 public void reset()
 {
     ROIList.Clear();
     activeROIidx = -1;
     ModelROI = null;
     roiMode = null;
     NotifyRCObserver(EVENT_DELETED_ALL_ROIS);
 }