Exemple #1
0
        /// <summary>
        /// Repaints the HALCON window 'window'
        /// </summary>
        public void repaint(HalconDotNet.HWindow window)
        {
            int          count = HObjList.Count;
            HObjectEntry entry;

            HSystem.SetSystem("flush_graphic", "false");
            window.ClearWindow();
            mGC.stateOfSettings.Clear();

            for (int i = 0; i < count; i++)
            {
                entry = ((HObjectEntry)HObjList[i]);
                mGC.applyContext(window, entry.gContext);
                window.DispObj(entry.HObj);
            }

            addInfoDelegate();

            if (roiManager != null && (dispROI == MODE_INCLUDE_ROI))
            {
                roiManager.paintData(window);
            }

            HSystem.SetSystem("flush_graphic", "true");

            window.SetColor("black");
            window.DispLine(-100.0, -100.0, -101.0, -101.0);
        }
Exemple #2
0
        /// <summary>
        /// Repaints the HALCON window 'window'
        /// </summary>
        public void repaint(HalconDotNet.HWindow window)
        {
            int h = imageHeight;

            if (window.IsInitialized() == false || viewPort.HalconID.ToInt32() == -1 || viewPort.ImagePart.Width <= 1 || viewPort.ImagePart.Height <= 1)
            {
                return;
            }
            int          count = HObjList.Count;
            HObjectEntry entry;

            HSystem.SetSystem("flush_graphic", "false");
            window.ClearWindow();
            mGC.stateOfSettings.Clear();

            for (int i = 0; i < count; i++)
            {
                entry = ((HObjectEntry)HObjList[i]);
                mGC.applyContext(window, entry.gContext);
                window.DispObj(entry.HObj);
            }

            addInfoDelegate();

            if (roiManager != null && (dispROI == MODE_INCLUDE_ROI))
            {
                roiManager.paintData(window);
            }

            HSystem.SetSystem("flush_graphic", "true");

            window.SetColor("black");
            window.DispLine(-100.0, -100.0, -101.0, -101.0);

            for (int i = 0; i < HMsgList.Count; i++)
            {
                if (HMsgList[i].Size != 0)
                {
                    set_display_font(viewPort.HalconID, HMsgList[i].Size, HMsgList[i].Font, HMsgList[i].Bold, HMsgList[i].Slant);
                }
                window.DispText(HMsgList[i].HMsg, HMsgList[i].coordSystem, HMsgList[i].row, HMsgList[i].column, HMsgList[i].color, HMsgList[i].genParamName, HMsgList[i].genParamValue);
            }
        }
Exemple #3
0
        /// <summary>
        /// Repaints the HALCON window 'window'
        /// </summary>
        private void repaint(HalconDotNet.HWindow window)
        {
            int count = HObjList.Count;

            if (count > 0)
            {
                HObjectEntry entry;
                HSystem.SetSystem("flush_graphic", "false");
                window.ClearWindow();
                mGC.stateOfSettings.Clear();
                for (int i = 0; i < count; i++)
                {
                    entry = ((HObjectEntry)HObjList[i]);
                    if (entry.colorShow.Length > 0)
                    {
                        window.SetColor(entry.colorShow);
                    }
                    mGC.applyContext(window, entry.gContext);
                    window.DispObj(entry.HObj);
                }
                if (roiManager != null)
                {
                    roiManager.paintData(window);
                }
                HSystem.SetSystem("flush_graphic", "true");
                window.DispLine(-100.0, -100.0, -101.0, -101.0);
            }
            count = StrList.Count;
            if (count > 0)
            {
                foreach (StringX strX in StrList)
                {
                    window.SetFont("-Consolas-" + strX.size.ToString() + "-*-" + (strX.bold ? "1" : "0") + "-*-*-" + (strX.slant ? "1" : "0") + "-");
                    window.SetColor(strX.color.Name.ToLower());
                    window.SetTposition(strX.row, strX.column);
                    window.WriteString(strX.str);
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Repaints the HALCON window 'window'
        /// </summary>
        public void repaint(HalconDotNet.HWindow window)
        {
            int h = imageHeight;

            if (window.IsInitialized() == false || viewPort.HalconID.ToInt32() == -1 || viewPort.ImagePart.Width <= 1 || viewPort.ImagePart.Height <= 1)
            {
                return;
            }
            int          count = HObjList.Count;
            HObjectEntry entry;

            HSystem.SetSystem("flush_graphic", "false");
            window.ClearWindow();
            mGC.stateOfSettings.Clear();

            for (int i = 0; i < count; i++)
            {
                entry = ((HObjectEntry)HObjList[i]);
                mGC.applyContext(window, entry.gContext);
                window.DispObj(entry.HObj);
            }

            addInfoDelegate();

            if (roiManager != null && (dispROI == MODE_INCLUDE_ROI))
            {
                roiManager.paintData(window);
            }

            HSystem.SetSystem("flush_graphic", "true");

            //window.SetColor("black");
            //window.DispLine(-100.0, -100.0, -101.0, -101.0);

            window.SetDraw("fill");
            //window.SetColored(12);
            window.SetColor("green");
        }
Exemple #5
0
        /// <summary>
        /// Repaints the HALCON window 'window'
        /// </summary>
        public void repaint(HalconDotNet.HWindow window)
        {
            lock (lockershow)
            {
                int count = HObjList.Count;
                //HObjectEntry entry;

                HSystem.SetSystem("flush_graphic", "false");
                window.ClearWindow();
                mGC.stateOfSettings.Clear();

                //for (int i = 0; i < count; i++)
                //{
                //    entry = ((HObjectEntry)HObjList[i]);
                //    mGC.applyContext(window, entry.gContext);
                //    window.DispObj(entry.HObj);
                //}
                if (entry != null)
                {
                    try
                    {
                        mGC.applyContext(window, entry.gContext);
                        window.DispObj(entry.HObj);
                    }
                    catch (Exception ex)
                    { }
                }
                addInfoDelegate();

                if (roiManager != null && (dispROI == MODE_INCLUDE_ROI))
                {
                    roiManager.paintData(window);
                }

                HSystem.SetSystem("flush_graphic", "true");

                if (myRect.Count != 0)
                {
                    window.SetColor("green");
                    window.SetLineWidth(2);
                    HObject ho_Rect = new HObject();

                    for (int i = 0; i < myRect.Count; i++)
                    {
                        if (myRect[i].isCircle)
                        {
                            window.SetColor("green");
                            window.SetLineWidth(2);
                            if (myRect[i].Found)
                            {
                                HOperatorSet.GenCircleContourXld(out ho_Rect, myRect[i].Y, myRect[i].X, myRect[i].Radius, 0, 6.28318, "positive", 1.0);
                                window.DispObj(ho_Rect);
                            }
                            //window.DispCircle(myRect[i].Y, myRect[i].X, myRect[i].Radius);
                            window.DispCross(myRect[i].Y, myRect[i].X, 50, 0);

                            disp_message(window, "X:" + myRect[i].X.ToString("F1") + ", Y:" + myRect[i].Y.ToString("F1") + ", Means:" + myRect[i].Means.ToString("F1"), "image", 100, 50, "green", "false");
                            disp_message(window, "Radius:" + myRect[i].Radius.ToString("F1") + ",Angle:" + Helper.GetDegreeFromRadian((float)myRect[i].Angle).ToString("F1"), "image", 300, 50, "green", "false");
                        }
                        else
                        {
                            window.SetColor("green");
                            window.SetLineWidth(2);
                            if (myRect[i].Found)
                            {
                                HOperatorSet.GenRectangle2ContourXld(out ho_Rect, myRect[i].Y, myRect[i].X, myRect[i].Angle, myRect[i].Width / 2, myRect[i].Height / 2);
                                window.DispObj(ho_Rect);
                            }
                            //if (myRect[i].Found)
                            //{
                            //window.SetColor("cyan");
                            //window.DispObj(myRect[i].rect_border);
                            //}
                            window.DispCross(myRect[i].Y, myRect[i].X, 50, 0);

                            disp_message(window, "X:" + myRect[i].X.ToString("F1") + ", Y:" + myRect[i].Y.ToString("F1") + ", Means:" + myRect[i].Means.ToString("F1"), "image", 100, 50, "green", "false");
                            disp_message(window, "Width:" + myRect[i].Width.ToString("F1") + ", Height:" + myRect[i].Height.ToString("F1"), "image", 300, 50, "green", "false");
                            //disp_message(window, "Means:" + myRect[i].Means.ToString("F1"), "image", 500, 50, "green", "false");
                        }
                    }

                    //for (int i = 0; i < myRect.Count; i++)
                    //    window.DispRectangle2(myRect[i].Y, myRect[i].X, myRect[i].Angle, myRect[i].Width / 2, myRect[i].Length / 2);
                }

                if (bShowCrossHair)
                {
                    window.SetColor("red");
                    window.SetLineWidth(2);
                    int winrow, winclom, winwidth, winHeight;
                    window.GetPart(out winrow, out winclom, out winwidth, out winHeight);
                    window.DispLine(winrow + (winwidth - winrow) / 2, (double)winclom, winrow + (winwidth - winrow) / 2, winHeight);
                    window.DispLine((double)winrow, winclom + (winHeight - winclom) / 2, winwidth, winclom + (winHeight - winclom) / 2);
                }

                if (IsDrawCross1)
                {
                    window.DispCross(200.0, 200.0, 40, 0);
                    //window.WriteString("标定1");
                }
                if (IsDrawCross2)
                {
                    //window.DispCross(200.0, 200.0, 2, 0);
                    window.DispCross(600.0, 600.0, 40, 0);
                    // window.WriteString("标定2");
                }
            }
        }
        /// <summary>
        /// Repaints the HALCON window 'window'
        /// </summary>
        public void repaint(HalconDotNet.HWindow window)
        {
            try
            {
                int          count = HObjList.Count;
                HObjectEntry entry;

                HSystem.SetSystem("flush_graphic", "false");
                window.ClearWindow();
                mGC.stateOfSettings.Clear();

                for (int i = 0; i < count; i++)
                {
                    entry = ((HObjectEntry)HObjList[i]);
                    mGC.applyContext(window, entry.gContext);
                    window.DispObj(entry.HObj);
                }

                addInfoDelegate();

                if (_roiManager != null && (_dispROI == MODE_INCLUDE_ROI))
                {
                    _roiManager.paintData(window);
                }


                var prevScaleC = (double)((ImgCol2 - ImgCol1) / imageWidth);
                foreach (var wViewModel in WriteStringList)
                {
                    window.SetColor("red");
                    HOperatorSet.SetTposition(window, wViewModel.Row, wViewModel.Col);
                    HOperatorSet.WriteString(window, wViewModel.Text);
                }
                //Display Arrow
                var arrowSize = 5 * prevScaleC;
                arrowSize = (arrowSize < 2) ? 2 : arrowSize;
                foreach (var arrowModel in ArrowList)
                {
                    HOperatorSet.DispArrow(window, arrowModel.CenterY, arrowModel.CenterX, arrowModel.FirstArrowY, arrowModel.FirstArrowX, arrowSize);
                    HOperatorSet.DispArrow(window, arrowModel.CenterY, arrowModel.CenterX, arrowModel.SecArrowY, arrowModel.SecArrowX, arrowSize);
                }

                //畫格線
                if (ShowGrid)
                {
                    drawGridLines(window);
                }
                HSystem.SetSystem("flush_graphic", "true");

                window.SetColor(this.RepaintWindowColor);
                window.DispLine(-100.0, -100.0, -101.0, -101.0);
            }
            catch (HOperatorException ex)
            {
                var errorNumber = ex.GetErrorNumber();

                /*
                 * 5106 發生情境為
                 * 1。開啟擷取影像後,未斷線就關閉 MDI 視窗
                 */
                if (errorNumber != 5106 && errorNumber != 5100)
                {
                    Hanbo.Log.LogManager.Error(ex);
                }
            }
        }