QQ群日志記錄
使用代碼設定所選模闆區域的中心原點,圖形界面中可以使用如下圖的按鈕來操作
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLicmbw5CO0YmNilTZ3EWO2AjMiRTOiJDZhF2NidTYkNDOihjZk9CX0JXZ252bj91Ztl2Lc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
C#代碼中可以使用如下的代碼來完成中心原點的設定:
private void PatternCenterPoint()
{
try
{
if (this.pmalign_.Pattern != null && this.pmalign_.Pattern.TrainImage != null && this.pmalign_.Pattern.TrainRegion != null)
{
ICogTransform2D transform = this.pmalign_.Pattern.TrainImage.GetTransform(".", this.pmalign_.Pattern.TrainRegion.SelectedSpaceName);
CogRectangle rectangle = this.pmalign_.Pattern.TrainRegion.Map(transform, CogCopyShapeConstants.GeometryOnly).EnclosingRectangle(CogCopyShapeConstants.GeometryOnly);
this.pmalign_.Pattern.Origin.TranslationX = rectangle.CenterX;
this.pmalign_.Pattern.Origin.TranslationY = rectangle.CenterY;
this.Display_.AutoFit = true;
}
}
catch (Exception e)
{
Common.MsgBox.show(e.Message);
}
}