Click or drag to resize

IDisplayOverlaysLinkFeatureToGraphObj Method

Link or unlink a feature with an McGraphObj instance.

Namespace:  MediaCy.IQL.Features
Assembly:  MediaCy.IQL.Features (in MediaCy.IQL.Features.dll) Version: 10.0.6912.0
Syntax
VB
Function LinkFeatureToGraphObj ( 
	lFeatureIndex As Integer,
	pimcgraphobjToLink As Object
) As Boolean

Parameters

lFeatureIndex
Type: SystemInt32
If non-negative, then it is the index of an existing feature to be linked (if the pimcgraphobjToLink argument is non-NULL). If lFeatureIndex is -1, then the given pimcgraphobjToLink is to be used to append a new feature if it is is of an appropriate class and has a TemplateID equal to the AutoDisplayTemplateID property. That is, this performs the same action that would be performed when a graph object is created by the user with a graphic tool (see McGraphOverlay.SelectTool). A linked feature is created and appended only if the pimcgraphobjToLink is of a class that matches a feature type (e.g., it is an McObjGraphLine and this is an McLines type of McFeatures). The pimcgraphobjToLink must also have a TemplateID property that is equal to our current AutoDisplayTemplateID property. If lFeatureIndex is -2, then the given pimcgraphobjToLink instance is to be unlinked rather than linked.
pimcgraphobjToLink
Type: SystemObject
If NULL, then all McGraphObj instances to which the lFeatureIndex'ed feature is linked are unlinked. If non-NULL, then this must be an instance of an McGraphObj-derived interface compatible with the lFeatureIndex'ed feature's type. The required McGraphObj ClassName property is given by the ClassNameForFeature method. If the McGraphObj's parent McGraphOverlay instance is not already a member of our McDisplayOverlays collection, it is Added automatically.

Return Value

Type: Boolean
VARIANT_BOOL - TRUE if the link is made.
Remarks
This method may be used to link a particular feature with an McGraphObj-derived instance for display. It may also be used to break the link between a given McGraphObj instance and whatever feature it is currently linked to, or to break the link between a given feature and all McGraphObj instances to which it is linked. This method rarely needs to be called, since feature display linking and unlinking is usually handled automatically by assigning a Template ID value to the AutoDisplayTemplateID property. The link will remain as long as the feature is not changed in such a way that its type changes or it needs to be completely recreated (see Example). When a link to a given pimcgraphobjToLink is explicitly broken (by passing in a -2 lFeatureIndex), then the unlinked McGraphObj instance is not Removed from its McGraphOverlay. If the link is broken any other way (by removing the linked feature, by passing a NULL pimcgraphobjToLink argument to explicitly unlinking all links to a linked feature, or by changing the type of the linked feature), then the Remove method is called on the unlinked McGraphObj (this will destroy the object unless someone is still holding a reference on it).
Examples
VB
'Show the Aoi in the Annotation overlay
Dim mrAoi As McRegions
Set mrAoi = ThisApplication.ActiveImage.Aoi
mrAoi.SetBox 0, 10, 10, 100, 100    ' make a mcftBox region
Dim strClassName As String ' Find ClassName for Aoi region 0
strClassName = mrAoi.DisplayOverlays.ClassNameForFeature 0
Dim mgovlAnnotation As McGraphOverlay
Set mgovlAnnotation = ThisApplication.ActiveImage.AnnotationOverlay
Dim goAoi As McGraphObj
goAoi = mgovlAnnotation.Add strClassName    'use default TemplateID
Results.Text = "Aoi McGraphObj ClassName is: " + goAoi.ClassName
' Set display properties
goAoi.BorderColor = &H00FF00    ' Green
goAoi.FillStyle = mcgfsBorderNoFill    ' No fill
goAoi.NotifyCreationComplete    ' Enable notifications
'Link Aoi region 0 with our new McGraphObj.
'AnnotationOverlay is added to DisplayOverlays automatically
mrAoi.DisplayOverlays.LinkFeatureToGraphObj 0, goAoi
mrAoi.Move 20, 20    'move the Aoi region, see the display move too
' Three ways to break the link
goAoi.Remove 'remove linked McGraphObj from the McGraphOverlay
mrAoi.SetEllipse 0,100,100,50 'change the type of the linked feature
mrAoi.DisplayOverlays.LinkFeatureToGraphObj -1, goAoi ' explicitly unlink
See Also