public void AddIconicVar(HWndMessage message)
        {
            HObjectEntry entry;

            if (message == null)
            {
                return;
            }
            entry = new HObjectEntry(message);
            HObjList.Add(entry);
            if (HObjList.Count > MAX_NUM_OBJ_LIST)
            {
                HObjList.RemoveAt(1);
            }
        }
        /// <summary>
        /// 添加图像变量
        /// </summary>
        /// <param name="obj"></param>
        public void AddIconicVar(HObject obj)
        {
            if (obj == null)
            {
                return;
            }
            //图片数据就更新长宽信息
            if (obj is HImage && obj.IsInitialized())
            {
                double r, c;
                int    h, w, area;
                string s;

                area = ((HImage)obj).GetDomain().AreaCenter(out r, out c);  //GetDomain该对象的整个作用域,ROI就是通过ReduceDomain()减少作用域来实现的。
                ((HImage)obj).GetImagePointer1(out s, out w, out h);

                //图像无论是否Domain(), w及h不会变化
                if ((h != imageHeight) || (w != imageWidth))
                {
                    //viewPort.HalconWindow.SetWindowParam("background_color", backguoundColor);
                    imageHeight = h;
                    imageWidth  = w;
                    ResetWindow();         //没有要求窗口是stretch模式,让该object对象填满整个窗口。
                }

                //面积=长*宽 表示对象作用域与该对象面积是相等的,那就代表整张原图像,而不是ROI对象。
                if (area == (w * h))
                {
                    ClearList();
                    isShowMessage = true;
                    resultShow    = ResultShow.处理后;
                }
            }

            HObjectEntry entry;

            entry = new HObjectEntry(obj, mGC.CopyContextList());
            //entry = new HObjectEntry(obj, new Hashtable());
            HObjList.Add(entry);
            if (HObjList.Count > MAX_NUM_OBJ_LIST)
            {
                HObjList.RemoveAt(1);             //HObjList[0]是模板图片,不能删除。
            }
        }
Example #3
0
        /// <summary>
        /// 添加图像变量
        /// </summary>
        /// <param name="obj"></param>
        public void AddIconicVar(HObject obj)
        {
            if (obj == null)
            {
                return;
            }
            //图片数据就更新长宽信息
            if (obj is HImage && obj.IsInitialized())
            {
                double r, c;
                int    h, w, area;
                string s;

                area = ((HImage)obj).GetDomain().AreaCenter(out r, out c);
                ((HImage)obj).GetImagePointer1(out s, out w, out h);

                //图像无论是否Domain(), w及h不会变化
                if ((h != imageHeight) || (w != imageWidth))
                {
#if NativeCode
                    Wrapper.ShowUnit.SetImageSize(viewPort.HalconWindow, w, h);
#else
                    //viewPort.HalconWindow.SetWindowParam("background_color", backguoundColor);
#endif

                    imageHeight = h;
                    imageWidth  = w;
                    ResetWindow();
                }

                //面积=长*宽 表示确实是图片
                if (area == (w * h))
                {
                    //viewPort.HalconWindow.AttachBackgroundToWindow((HImage)obj);

                    //HTuple winid = 1;
                    //Wrapper.ShowUnit.ClearEntryList(viewPort.HalconWindow);
                    //ResetWindow();
                    ClearList();
                    isShowMessage = true;
                    resultShow    = ResultShow.处理后;
                    //if ((h != imageHeight) || (w != imageWidth))
                    //{
                    //    imageHeight = h;
                    //    imageWidth = w;
                    //    Wrapper.ShowUnit.ClearEntryList(viewPort.HalconWindow);
                    //    ResetWindow();
                    //}
                }
            }

#if NativeCode
            Wrapper.ShowUnit.AddIconicVar(viewPort.HalconWindow, obj);
#else
            HObjectEntry entry;
            entry = new HObjectEntry(obj, mGC.CopyContextList());
            //entry = new HObjectEntry(obj, new Hashtable());
            HObjList.Add(entry);

            if (HObjList.Count > MAX_NUM_OBJ_LIST)
            {
                HObjList.RemoveAt(1);
            }
#endif
        }