Esempio n. 1
0
        /// <summary>
        /// 重新开辟内存保存 防止被传入的HObject在其他地方dispose后,不能重现
        /// </summary>
        /// <param name="hObj">传入的region.xld,image</param>
        /// <param name="color">颜色</param>
        public void DispObj(HobjectString hobjectString, HObject hObj, string color, string draw)
        {
            lock (this)
            {
                //显示指定的颜色
                if (color != null)
                {
                    HOperatorSet.SetColor(viewPort.HalconWindow, color);
                }
                else
                {
                    HOperatorSet.SetColor(viewPort.HalconWindow, "red");
                }
                //显示指定的模式
                if (draw != null)
                {
                    HOperatorSet.SetDraw(viewPort.HalconWindow, draw);
                }
                else
                {
                    HOperatorSet.SetDraw(viewPort.HalconWindow, "margin");
                }
                if (hobjectString != null)
                {
                    HOperatorSet.SetTposition(viewPort.HalconWindow, hobjectString.Y, hobjectString.X);
                    hObjectList.Add(new HObjectWithColor(hobjectString, color));
                    HOperatorSet.WriteString(viewPort.HalconWindow, hobjectString.str);
                }
                else
                {
                    if (hObj != null && hObj.IsInitialized())
                    {
                        //
                        HObject temp = new HObject(hObj);
                        //
                        hObjectList.Add(new HObjectWithColor(temp, color, draw));

                        viewPort.HalconWindow.DispObj(temp);
                    }
                }

                //恢复默认的红色和显示方式
                HOperatorSet.SetColor(viewPort.HalconWindow, "red");
                HOperatorSet.SetDraw(viewPort.HalconWindow, "margin");
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 默认红颜色显示
 /// </summary>
 /// <param name="hObj">传入的region.xld,image</param>
 public void DispObj(HobjectString hobjectString, HObject hObj, string draw)
 {
     DispObj(hobjectString, hObj, null, draw);
 }