【实例简介】
【实例截图】
【核心代码】
using System;
using HalconDotNet;
using ViewROI;
using System.Collections;
namespace ViewROI
{
public delegate void FuncROIDelegate();
///
/// This class creates and manages ROI objects. It responds
/// to mouse device inputs using the methods mouseDownAction and
/// mouseMoveAction. You don't have to know this class in detail when you
/// build your own C# project. But you must consider a few things if
/// you want to use interactive ROIs in your application: There is a
/// quite close connection between the ROIController and the HWndCtrl
/// class, which means that you must 'register' the ROIController
/// with the HWndCtrl, so the HWndCtrl knows it has to forward user input
/// (like mouse events) to the ROIController class.
/// The visualization and manipulation of the ROI objects is done
/// by the ROIController.
/// This class provides special support for the matching
/// applications by calculating a model region from the list of ROIs. For
/// this, ROIs are added and subtracted according to their sign.
///
public class ROIController
{
public delegate void UpdateEventHandler(int handle);
public event UpdateEventHandler ROI_Update;
///
/// Constant for setting the ROI mode: positive ROI sign.
///
public const int MODE_ROI_POS = 21;
///
/// Constant for setting the ROI mode: negative ROI sign.
///
public const int MODE_ROI_NEG = 22;
///
/// Constant for setting the ROI mode: no model region is computed as
/// the sum of all ROI objects.
///
public const int MODE_ROI_NONE = 23;
/// Constant describing an update of the model region
public const int EVENT_UPDATE_ROI = 50;
public const int EVENT_CHANGED_ROI_SIGN = 51;
/// Constant describing an update of the model region
public const int EVENT_MOVING_ROI = 52;
public const int EVENT_DELETED_ACTROI = 53;
public const int EVENT_DELETED_ALL_ROIS = 54;
public const int EVENT_ACTIVATED_ROI = 55;
public const int EVENT_CREATED_ROI = 56;
private ROI roiMode;
private int stateROI;
private double currX, currY;
/// Index of the active ROI