11.5   Visualization

Applications can use an instance of HSmartWindowControl to display results. However, this is only available for .NET Framework and the MVTec.HalconDotNet-Windows .NET Core packages. How to configure this control is described in section “Adding and Customizing HSmartWindowControl for the Visualization”. The actual display operators, however, do not use the control but the HALCON graphics window (class HWindow) encapsulated inside. You can access the graphics window via the property HalconWindow of HSmartWindowControl:

private HWindow                       Window;

private void Form1_Load(object sender, System.EventArgs e)
{
  Window = WindowControl.HalconWindow;
}

In the code above, the variable for the instance of HWindow was declared globally and initialized in the event Load of the form.

You can configure the display parameters like pen color or line width with the operators in the reference manual chapter Graphics→Parameters:

Window.SetDraw("margin");
Window.SetLineWidth(3);

Images and other iconic objects are displayed with the operator DispObj, which can be called via the object to display with the window as parameter or vice versa:

Img.DispObj(Window);

More display operators, e.g., to display lines or circles, can be found in the reference manual chapter Graphics→Output.

Instead of (or in addition to) using HSmartWindowControl, you can also open a HALCON graphics windows directly with the operator OpenWindow:

HWindow ZoomWindow = new HWindow(0, 0, width, height, 0, "visible", "");

In the code above, the window was opened “free-floating” on the display. You can also open it within another GUI element by passing its handle in the parameter fatherWindow.

Before displaying anything in the graphics window, you should set the image part to display with the operator SetPart. In the example code below, the opened window is used to display a zoomed part of the image:

ZoomWindow.SetPart(row1, col1, row1+height-1, col1+width-1);

More information about visualization in general can be found in the Solution Guide I. Note that in this manual, the HDevelop version of the display operators is used, i.e., with the prefix dev_, e.g., dev_open_window instead of OpenWindow.