/// <summary>
        /// Paints the active handle of the ROI object into the supplied window
        /// </summary>
        /// <param name="window">HALCON window</param>
        public override void displayActive(HalconDotNet.HWindow window)
        {
            if (!SizeEnable || !ShowRect)
            {
                return;
            }

            int hrow, hcol, hw, hh;

            window.GetPart(out hrow, out hcol, out hh, out hw);
            int wrow, wcol, ww, wh;

            window.GetWindowExtents(out wrow, out wcol, out ww, out wh);

            double smallregionwidth  = (hw - hcol) * windowsmallregionwidth / ww;
            double smallregionheight = (hh - hrow) * windowsmallregionwidth / wh;

            window.DispRectangle2(rows[activeHandleIdx].D,
                                  cols[activeHandleIdx].D,
                                  phi, smallregionwidth, smallregionheight);

            if (activeHandleIdx == 5)
            {
                window.DispArrow(midR, midC,
                                 midR + (Math.Sin(-phi) * length1 * 1.2),
                                 midC + (Math.Cos(-phi) * length1 * 1.2),
                                 2.0);
            }
        }
        public int windowsmallregionwidth = 5;//4边小矩形的大小
        /// <summary>Paints the ROI into the supplied window</summary>
        /// <param name="window">HALCON window</param>
        public override void draw(HalconDotNet.HWindow window)
        {
            window.DispRectangle1(row1, col1, row2, col2);
            if (SizeEnable && ShowRect)
            {
                int hrow, hcol, hw, hh;
                window.GetPart(out hrow, out hcol, out hh, out hw);
                int wrow, wcol, ww, wh;
                window.GetWindowExtents(out wrow, out wcol, out ww, out wh);

                double smallregionwidth  = (hw - hcol) * windowsmallregionwidth / ww;
                double smallregionheight = (hh - hrow) * windowsmallregionwidth / wh;
                //焦点小矩形最小为5
                if (smallregionwidth < 5)
                {
                    smallregionwidth = 5;
                }
                if (smallregionheight < 5)
                {
                    smallregionheight = 5;
                }

                window.DispRectangle2(row1, col1, 0, smallregionheight, smallregionwidth);
                window.DispRectangle2(row1, col2, 0, smallregionheight, smallregionwidth);
                window.DispRectangle2(row2, col2, 0, smallregionheight, smallregionwidth);
                window.DispRectangle2(row2, col1, 0, smallregionheight, smallregionwidth);
                window.DispRectangle2(midR, midC, 0, smallregionheight, smallregionwidth);
            }
        }
Exemple #3
0
        /// <summary>
        /// Paints the active handle of the ROI object into the supplied window.
        /// </summary>
        public override void displayActive(HalconDotNet.HWindow window)
        {
            if (!SizeEnable || !ShowRect)
            {
                return;
            }
            int hrow, hcol, hw, hh;

            window.GetPart(out hrow, out hcol, out hh, out hw);
            int wrow, wcol, ww, wh;

            window.GetWindowExtents(out wrow, out wcol, out ww, out wh);

            double smallregionwidth  = (hw - hcol) * windowsmallregionwidth / ww;
            double smallregionheight = (hh - hrow) * windowsmallregionwidth / wh;

            switch (activeHandleIdx)
            {
            case 0:
                window.DispRectangle2(row1, col1, 0, smallregionheight, smallregionwidth);
                break;

            case 1:
                window.DispObj(arrowHandleXLD);                         //window.DispRectangle2(row2, col2, 0, 5, 5);
                break;

            case 2:
                window.DispRectangle2(midR, midC, 0, smallregionheight, smallregionwidth);
                break;
            }
        }
Exemple #4
0
        public int windowsmallregionwidth = 5;//4边小矩形的大小
        /// <summary>Paints the ROI into the supplied window.</summary>
        public override void draw(HalconDotNet.HWindow window)
        {
            window.DispLine(row1, col1, row2, col2);

            if (SizeEnable && ShowRect)
            {
                int hrow, hcol, hw, hh;
                window.GetPart(out hrow, out hcol, out hh, out hw);
                int wrow, wcol, ww, wh;
                window.GetWindowExtents(out wrow, out wcol, out ww, out wh);

                double smallregionwidth  = (hw - hcol) * windowsmallregionwidth / ww;
                double smallregionheight = (hh - hrow) * windowsmallregionwidth / wh;

                window.DispRectangle2(row1, col1, 0, smallregionheight, smallregionwidth);
                window.DispObj(arrowHandleXLD);  //window.DispRectangle2( row2, col2, 0, 5, 5);
                window.DispRectangle2(midR, midC, 0, smallregionheight, smallregionwidth);
            }
        }
        public int windowsmallregionwidth = 5;//4边小矩形的大小
        /// <summary>Paints the ROI into the supplied window</summary>
        /// <param name="window">HALCON window</param>
        public override void draw(HalconDotNet.HWindow window)
        {
            window.DispRectangle2(midR, midC, phi, length1, length2);
            if (SizeEnable && ShowRect)
            {
                int hrow, hcol, hw, hh;
                window.GetPart(out hrow, out hcol, out hh, out hw);
                int wrow, wcol, ww, wh;
                window.GetWindowExtents(out wrow, out wcol, out ww, out wh);

                double smallregionwidth  = (hw - hcol) * windowsmallregionwidth / ww;
                double smallregionheight = (hh - hrow) * windowsmallregionwidth / wh;

                for (int i = 0; i < NumHandles; i++)
                {
                    window.DispRectangle2(rows[i].D, cols[i].D, phi, smallregionwidth, smallregionheight);
                }

                window.DispArrow(midR, midC, midR + (Math.Sin(-phi) * length1 * 1.2),
                                 midC + (Math.Cos(-phi) * length1 * 1.2), 2.0);
            }
        }
Exemple #6
0
        public int windowsmallregionwidth = 5;//小矩形的大小
        public override void draw(HalconDotNet.HWindow window)
        {
            //window.SetColor("white");
            //window.SetLineStyle(0);
            //window.SetLineWidth(1);
            window.DispRegion(mCurHRegion);

            if (SizeEnable && ShowRect)
            {
                int hrow, hcol, hw, hh;
                window.GetPart(out hrow, out hcol, out hh, out hw);
                int wrow, wcol, ww, wh;
                window.GetWindowExtents(out wrow, out wcol, out ww, out wh);

                double smallregionwidth  = (hw - hcol) * windowsmallregionwidth / ww;
                double smallregionheight = (hh - hrow) * windowsmallregionwidth / wh;

                double midR, midC;
                this.getRegion().AreaCenter(out midR, out midC);

                window.DispRectangle2(midR, midC, 0, smallregionheight, smallregionwidth);
            }
        }
Exemple #7
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");
                }
            }
        }