IMcEngineCreateOperator Method
|
|
Create an "operator and store a connection to it in the Object
Manager.
Namespace:
MediaCy.IQL.Engine
Assembly:
MediaCy.IQL.Engine (in MediaCy.IQL.Engine.dll) Version: 10.0.6912.0
SyntaxFunction CreateOperator (
ProgIDorCLSID As String,
<OptionalAttribute> varParent As Object,
Optional Name As String = ""
) As Object
Parameters
- ProgIDorCLSID
- Type: SystemString
Registered Prog ID of the "coclass" of this object. Or the
CLSID in a form like "{DC2F6FCB-08A7-40c0-BBDB-D3894B1C5F68}"; the braces
are required. If the class has already been registered with the McObjects
object manager, then just the registered type name is required. The
registered type name is the portion of the ProgID after the first period up
to any second period. All coclasses in the Image Pro type library are
registered at start up, so as illustrated in the examples, you can just use
the type name for virtually all "operators".
As illustrated in Example 3, if a Name is given of an existing McObject or
operator, then you may optionally leave the ClassID blank. If you do supply
a ClassID along with a Name, then any existing operator of the given name
must match the registered type of the ClassID argument. - varParent (Optional)
- Type: SystemObject
[in,optional] If given, a parent operator interface or
the McObject of the parent operator interface. If no parent is given, then
a "global" instance of the operator interface is created. Most operators
require a particular type of parent or ancestor to function (e.g., the
McHistogram operator shown in the first example needs to be a descendent of a
McImage instance). The CreateOperator method may fail if the proper type
of parent is not supplied. - Name (Optional)
- Type: SystemString
[in,defaultvalue("")] If given, the name of an existing
operator of type ClassID, or the name to be given to a newly created
operator. If a new operator is given a Name, the operator will not be
released until it's McObject is removed from the McObject's collection; see
Example 2. If no name is given, then the operator is released as soon as
the returned interface is; see Example 1.
Named operators with a parent operator can be accessed from VB as if they
were a built-in property (see Example 2).
Return Value
Type:
ObjectThe new or existing interface instance.
RemarksThis function provides a convenient way to create an "operator" (an interface
implementing IMcHasObject) and registering it in the McObjects Object Manager. This
enables the interface to receive notifications and access other registered objects like
McEngine or McEngine.Images.
You may optionally specify a parent operator (or its connected McObject) and/or
a name. If both a name and parent operator are given, then the object becomes
available by name from VB (see Example 2).
Note |
---|
If a Name of an existing operator is supplied, CreateOperator will return
any existing operator of the same parent, name and type. An error is generated
if the Name is of the wrong type for a given ClassID argument.
If the object is created (that is, an object of a given name did not already
exist), then it is part of an McObjects category named "CreatedOperator".
Named operators are not released until their backing McObject is removed from
the McObjects collection. This happens automatically when the parent operator
is removed from the collection. Thus in Example 2, the newly created operator
named "MyAoiCopy" would be removed from the collection and released as
soon as the ThisApplication.ActiveImage was closed, even without the last line in the example. |
Examples
Public Sub PrivateHistogram()
Dim myHistogram As MediaCy.Iql.Operations.McHistogram
myHistogram = ThisApplication.CreateOperator("McHistogram", ThisApplication.ActiveImage)
myHistogram.BinCount = 4
Dim Ch0Bins As Object = myHistogram.Values(-1,0)
Dim strBins As String = ThisApplication.GlobalTools.McToText(Ch0Bins).Value()
MsgBox( "Counts in the four bins from Ch0 are " + strBins)
myHistogram = Nothing
End Sub
Public Sub NamedMcRegionsOperator()
Dim mcregionsAoiCopy As MediaCy.IQL.Features.McRegions
mcregionsAoiCopy = ThisApplication.CreateOperator("McRegions", ThisApplication.ActiveImage, "MyAoiCopy")
mcregionsAoiCopy.CopyFrom ThisApplication.ActiveImage.Aoi
ThisApplication.ActiveImage.Aoi.Reset
mcregionsAoiCopy = Nothing
MsgBox("Aoi should be clear now.",,"NamedMcRegionsOperator")
ThisApplication.ActiveImage.Aoi.CopyFrom ThisApplication.ActiveImage.MyAoiCopy
MsgBox("Aoi should be restored now.",,"NamedMcRegionsOperator")
ThisApplication.McObject(ThisApplication.ActiveImage.MyAoiCopy).KillObjectAndChildren
End Sub
Public Sub AccessExistingOperator()
Dim mcregionsAoi As MediaCy.IQL.Features.McRegions
mcregionsAoi = ThisApplication.CreateOperator("", ThisApplication.ActiveImage, "Aoi")
MsgBox("The Aoi has " + CStr(mcregionsAoi.Count) + " individual features.")
mcregionsAoi = ThisApplication.ActiveImage.Aoi
MsgBox("The Aoi is of the following overall type: " + Format(mcregionsAoi.Type(-1),"X")) + " hex."
End Sub
See AlsoReference
The
standard
in
Microsoft
[T:MediaCy.IQL.Engine.IMcEngine.]