// 2014.09.02 public void SetInitSearchRegion(double dX, double dY) { m_dInitSearchRegionX = dX; m_dInitSearchRegionY = dY; ICogRegion region = m_icogRegion; if (region is CogCircle) { CogCircle circle = region as CogCircle; circle.CenterX = m_dInitSearchRegionX; circle.CenterY = m_dInitSearchRegionY; } else if (region is CogEllipse) { CogEllipse ellipse = region as CogEllipse; ellipse.CenterX = m_dInitSearchRegionX; ellipse.CenterY = m_dInitSearchRegionY; } else if (region is CogRectangle) { CogRectangle rectangle = region as CogRectangle; rectangle.X = m_dInitSearchRegionX; rectangle.Y = m_dInitSearchRegionY; } else if (region is CogRectangleAffine) { CogRectangleAffine rectangleAffine = region as CogRectangleAffine; rectangleAffine.CenterX = m_dInitSearchRegionX; rectangleAffine.CenterY = m_dInitSearchRegionY; } else if (region is CogCircularAnnulusSection) { CogCircularAnnulusSection circularAnnuluns = region as CogCircularAnnulusSection; circularAnnuluns.CenterX = m_dInitSearchRegionX; circularAnnuluns.CenterY = m_dInitSearchRegionY; } else if (region is CogEllipticalAnnulusSection) { CogEllipticalAnnulusSection ellipticalAnnuluns = region as CogEllipticalAnnulusSection; ellipticalAnnuluns.CenterX = m_dInitSearchRegionX; ellipticalAnnuluns.CenterY = m_dInitSearchRegionY; } }
// 2014.09.02 public void MoveSearchRegion(double x, double y) { m_dMoveSearchRegionX = x; m_dMoveSearchRegionY = y; ICogRegion region = m_icogRegion; if (region is CogCircle) { CogCircle circle = region as CogCircle; circle.CenterX = m_dInitSearchRegionX + x; circle.CenterY = m_dInitSearchRegionY + y; } else if (region is CogEllipse) { CogEllipse ellipse = region as CogEllipse; ellipse.CenterX = m_dInitSearchRegionX + x; ellipse.CenterY = m_dInitSearchRegionY + y; } else if (region is CogRectangle) { CogRectangle rectangle = region as CogRectangle; rectangle.X = m_dInitSearchRegionX + x; rectangle.Y = m_dInitSearchRegionY + y; } else if (region is CogRectangleAffine) { CogRectangleAffine rectangleAffine = region as CogRectangleAffine; rectangleAffine.CenterX = m_dInitSearchRegionX + x; rectangleAffine.CenterY = m_dInitSearchRegionY + y; } else if (region is CogCircularAnnulusSection) { CogCircularAnnulusSection circularAnnuluns = region as CogCircularAnnulusSection; circularAnnuluns.CenterX = m_dInitSearchRegionX + x; circularAnnuluns.CenterY = m_dInitSearchRegionY + y; } else if (region is CogEllipticalAnnulusSection) { CogEllipticalAnnulusSection ellipticalAnnuluns = region as CogEllipticalAnnulusSection; ellipticalAnnuluns.CenterX = m_dInitSearchRegionX + x; ellipticalAnnuluns.CenterY = m_dInitSearchRegionY + y; } }
// 2014.09.02 public void SetInitSearchRegion() { ICogRegion region = m_icogRegion; if (region is CogCircle) { CogCircle circle = region as CogCircle; m_dInitSearchRegionX = circle.CenterX - m_dMoveSearchRegionX; m_dInitSearchRegionY = circle.CenterY - m_dMoveSearchRegionY; } else if (region is CogEllipse) { CogEllipse ellipse = region as CogEllipse; m_dInitSearchRegionX = ellipse.CenterX - m_dMoveSearchRegionX; m_dInitSearchRegionY = ellipse.CenterY - m_dMoveSearchRegionY; } else if (region is CogRectangle) { CogRectangle rectangle = region as CogRectangle; m_dInitSearchRegionX = rectangle.X - m_dMoveSearchRegionX; m_dInitSearchRegionY = rectangle.Y - m_dMoveSearchRegionY; } else if (region is CogRectangleAffine) { CogRectangleAffine rectangleAffine = region as CogRectangleAffine; m_dInitSearchRegionX = rectangleAffine.CenterX - m_dMoveSearchRegionX; m_dInitSearchRegionY = rectangleAffine.CenterY - m_dMoveSearchRegionY; } else if (region is CogCircularAnnulusSection) { CogCircularAnnulusSection circularAnnuluns = region as CogCircularAnnulusSection; m_dInitSearchRegionX = circularAnnuluns.CenterX - m_dMoveSearchRegionX; m_dInitSearchRegionY = circularAnnuluns.CenterY - m_dMoveSearchRegionY; } else if (region is CogEllipticalAnnulusSection) { CogEllipticalAnnulusSection ellipticalAnnuluns = region as CogEllipticalAnnulusSection; m_dInitSearchRegionX = ellipticalAnnuluns.CenterX - m_dMoveSearchRegionX; m_dInitSearchRegionY = ellipticalAnnuluns.CenterY - m_dMoveSearchRegionY; } }
public bool GrabRegion(ADisplay aDisplay, AVisionProBuild._emRegionShape emRegionShape) { aDisplay.ClearOverlay(); ICogGraphicInteractive icogGraphInteractive = null; ICogRegion icogRegion = m_cogBlobTool.Region; CogCircle circle = icogRegion as CogCircle; CogEllipse ellipse = icogRegion as CogEllipse; CogRectangle rectangle = icogRegion as CogRectangle; CogRectangleAffine rectangleAffine = icogRegion as CogRectangleAffine; CogCircularAnnulusSection circularAnnuluns = icogRegion as CogCircularAnnulusSection; CogEllipticalAnnulusSection ellipticalAnnuluns = icogRegion as CogEllipticalAnnulusSection; switch (emRegionShape) { case AVisionProBuild._emRegionShape.Circle: { if (circle == null) { circle = new CogCircle(); circle.FitToImage(aDisplay.GetImage8Grey(), 0.5, 0.5); } icogGraphInteractive = circle as ICogGraphicInteractive; } break; case AVisionProBuild._emRegionShape.Ellipse: { if (ellipse == null) { ellipse = new CogEllipse(); ellipse.FitToImage(aDisplay.GetImage8Grey(), 0.5, 0.5); } icogGraphInteractive = ellipse as ICogGraphicInteractive; } break; case AVisionProBuild._emRegionShape.Rectangle: { if (rectangle == null) { rectangle = new CogRectangle(); rectangle.FitToImage(aDisplay.GetImage8Grey(), 0.5, 0.5); } icogGraphInteractive = rectangle as ICogGraphicInteractive; } break; case AVisionProBuild._emRegionShape.RectangleAffine: { if (rectangleAffine == null) { rectangleAffine = new CogRectangleAffine(); rectangleAffine.FitToImage(aDisplay.GetImage8Grey(), 0.5, 0.5); } icogGraphInteractive = rectangleAffine as ICogGraphicInteractive; } break; case AVisionProBuild._emRegionShape.CircularAnnulusSection: { if (circularAnnuluns == null) { circularAnnuluns = new CogCircularAnnulusSection(); circularAnnuluns.FitToImage(aDisplay.GetImage8Grey(), 0.5, 0.5); } icogGraphInteractive = circularAnnuluns as ICogGraphicInteractive; } break; case AVisionProBuild._emRegionShape.EllipticalAnnulusSection: { if (ellipticalAnnuluns == null) { ellipticalAnnuluns = new CogEllipticalAnnulusSection(); ellipticalAnnuluns.FitToImage(aDisplay.GetImage8Grey(), 0.5, 0.5); } icogGraphInteractive = ellipticalAnnuluns as ICogGraphicInteractive; } break; case AVisionProBuild._emRegionShape.Entire: { m_icogRegion = null; aDisplay.ClearOverlay(); } break; default: m_icogRegion = null; return(false); } if (icogGraphInteractive != null) { icogGraphInteractive.GraphicDOFEnableBase = CogGraphicDOFConstants.All; icogGraphInteractive.Interactive = true; icogGraphInteractive.TipText = "Region of Interest"; aDisplay.AddOverlay(icogGraphInteractive, ""); } return(true); }