public void AttachDrawObj(HDrawingObject obj) { drawing_objects.Add(obj); obj.OnDrag(SobelFilter); obj.OnAttach(SobelFilter); obj.OnResize(SobelFilter); obj.OnSelect(OnSelectDrawingObject); obj.OnAttach(SobelFilter); //HObject region = null; //if (obj.GetDrawingObjectParams("type") == "line") //{ // HTuple a = obj.GetDrawingObjectParams("row1"); // HOperatorSet.GenRegionLine(out region, obj.GetDrawingObjectParams("row1"), // obj.GetDrawingObjectParams("column1"), obj.GetDrawingObjectParams("row2"), // obj.GetDrawingObjectParams("column2")); //} //else //{ // region = new HRegion(obj.GetDrawingObjectIconic()); //} //AddToStack(region); if (selected_drawing_object == null) { selected_drawing_object = obj; } // hsmartControl.HalconWindow.AttachDrawingObjectToWindow(obj); HOperatorSet.AttachDrawingObjectToWindow(m_windowHandle, obj); }
private void SetCallbacks(HTuple draw_id) { // Set callbacks for all relevant interactions drawing_objects.Add(draw_id); IntPtr ptr = Marshal.GetFunctionPointerForDelegate(cb); HOperatorSet.SetDrawingObjectCallback(draw_id, "on_resize", ptr); HOperatorSet.SetDrawingObjectCallback(draw_id, "on_drag", ptr); HOperatorSet.SetDrawingObjectCallback(draw_id, "on_attach", ptr); HOperatorSet.SetDrawingObjectCallback(draw_id, "on_select", ptr); lock (image_lock) { HOperatorSet.AttachDrawingObjectToWindow(hSmartWindowControlWPF1.HalconID, draw_id); } }
private void btnEditROI_Click(object sender, EventArgs e) { if (!editingROI) { BackuptButtonColor = (sender as Button).BackColor; (sender as Button).BackColor = Color.Silver; editingROI = true; // Find Small Rectangle HTuple rRow1, rCol1, rRow2, rCol2; HOperatorSet.SmallestRectangle1(CurrentCodeReader.ROI, out rRow1, out rCol1, out rRow2, out rCol2); HOperatorSet.CreateDrawingObjectRectangle1(rRow1, rCol1, rRow2, rCol2, out tempDrawingRect); // Display HOperatorSet.AttachDrawingObjectToWindow(DisplayWD, tempDrawingRect); } else { editingROI = false; (sender as Button).BackColor = BackuptButtonColor; HOperatorSet.DetachDrawingObjectFromWindow(DisplayWD, tempDrawingRect); HTuple edittingROI; try { HOperatorSet.GetDrawingObjectParams(tempDrawingRect, new HTuple("row1", "column1", "row2", "column2"), out edittingROI); HObject tempROI = new HRegion((HTuple)edittingROI[0], (HTuple)edittingROI[1], (HTuple)edittingROI[2], (HTuple)edittingROI[3]); CurrentCodeReader.ROI = tempROI; HOperatorSet.DispObj(CurrentCodeReader.ROI, DisplayWD); } catch { HOperatorSet.DispObj(CurrentCodeReader.ROI, DisplayWD); return; } } }