Click or drag to resize

IDisplayedObjectsSetLabelText Method

The Label for each of the McGraphObj instances is displayed or cleared.

Namespace:  MediaCy.IQL.Features
Assembly:  MediaCy.IQL.Features (in MediaCy.IQL.Features.dll) Version: 10.0.6912.0
Syntax
VB
Sub SetLabelText ( 
	bstrLabelTextOrKeyword As String,
	Optional mcsltFlags As mcSetLabelTextFlags = mcSetLabelTextFlags.mcsltDefault,
	Optional lTextColor As Integer = -1,
	<OptionalAttribute> varIFontDisp As Object
)

Parameters

bstrLabelTextOrKeyword
Type: SystemString
mcsltFlags (Optional)
Type: MediaCy.IQL.FeaturesmcSetLabelTextFlags
This argument holds three sets of flags. One set controls which number is passed to the display text formatting string (linked feature index, linked feature Identifier, the McFeatures.SourceData property or McGraphObj ID). The second set of flags controls whether the label TextColor property is automatically copied from the McGraphObj BorderColor or FillColor properties. The third set of flags controls the position of the label relative to the McGraphObj. These flags are identical to the similarly named mcGraphObjStyle bits that control label placement in the McGraphObj.Style property. Should all of the placement flags be off, then any label is removed.
lTextColor (Optional)
Type: SystemInt32
If not -1 (the default), then this is the TextColor property to set for the labels. Any value other than -1 will override any mcsltFlags setting the TextColor. If -1 and neither the mcsltCopyBorderColor nor mcsltCopyFillColor mcsltFlags are given, then the label color is left alone.
varIFontDisp (Optional)
Type: SystemObject
If given, a standard IFontDisp interface instance that describes the font to use for the text display. If not given, the default font for the label text is used.
Remarks
With a single call to this method, the label text can be set as well as the label position and the label text color.
Examples
VB
'Example 1: Set the label of all thresholded sub-regions in the
'ActiveImage.RegionsFeatures object to have a label showing "Idx=sub-region index".
'The label will be centered within the region and the label color will
'be set to green.  The default font will be used except that it will
'be made italic and 10 point.
'
With ThisApplication.ActiveImage.RegionFeatures
.Threshold.Execute  'Get some regions
Dim myFont As IFontDisp
Set myFont = .AutoDisplayOverlay.Template("McGraphObjText").Font 'Start with default font
myFont.Italic = True
myFont.Size = 10
.DisplayedObjects.SetLabelText "Idx=%d", _
mcsltDisplayFeatureIndex Or mcsltLabelCenter, &HFF00&, myFont
End With
'Example 2: Label regions with their area
'
With ThisApplication.ActiveImage.RegionFeatures
Dim varAreas As Variant
varAreas = .mRgnArea
Dim lF As Long
For lF = 0 to .Count-1
.SourceData(lF) = CDbl(varAreas(lF))
Next lF
.DisplayedObjects.SetLabelText "%.1f", _
mcsltDisplaySourceData Or mcsltLabelCenter, &HFF00&, myFont
End With
'Example 3: Label regions that have holes with the number of holes
'
With ThisApplication.ActiveImage.RegionFeatures
.SourceFlags = .mRgnNumHoles
.DisplayedObjects(McOpNE(.mRgnNumHoles,0)).SetLabelText "N holes: %d", _
mcsltDisplaySourceFlags Or mcsltLabelTopleft
End With
'Example 4: Label small vs large regions
'
Dim varAreas, varMeanArea
varAreas = ThisApplication.ActiveImage.RegionFeatures.mRgnArea
varMeanArea = McSum(varAreas) / ThisApplication.ActiveImage.RegionFeatures.mRgnArea.Count
Results.Text = "There are " + Str(ActiveImage.RegionFeatures.mRgnArea.Count) + _
" regions. The mean Area is: " + McToText(varMeanArea, "%.2f")
'Get selectors for small areas and for not small (large) areas
Dim selSmallAreas, selLargeAreas
selSmallAreas = McOpLE(varAreas, varMeanArea)
selLargeAreas = McOpNOT(selSmallAreas)
Dim mdobjsSmall As IDisplayedObjects
' Set mdobjsSmall = ThisApplication.ActiveImage.RegionFeatures.DisplayedObjects(selSmallAreas, , ,mcdoAllOverlays)
' Set mdobjsSmall = ThisApplication.ActiveImage.RegionFeatures.DisplayedObjects(selSmallAreas)
' the above works just fine, below is a full equivalent call
varTemplateIDList = Array(mcgtStandardAutoDisplay, mcgtDefaultTemplate)
Set mdobjsSmall = ThisApplication.ActiveImage.RegionFeatures.DisplayedObjects(selSmallAreas, _
s_mcgraphoverlayToUse, varTemplateIDList)
' Now label the small regions in yellow, using the default font
mdobjsSmall.SetLabelText "%d:Sm", _
mcsltDisplayFeatureIndex + mcsltLabelCenter, &HFFFF&
' Label large objects on all overlays
Dim mdobjsLarge As IDisplayedObjects
Set mdobjsLarge = ThisApplication.ActiveImage.RegionFeatures.DisplayedObjects(selLargeAreas, , , mcdoAllOverlays)
' Now label the Large regions with the border color, using a different font
Dim imcgraphobjTemplate As IMcGraphObj
Set imcgraphobjTemplate = s_mcgraphoverlayToUse.Template("McGraphObj", mcgtStandardAutoDisplay)
Dim ifontdispLabel As IFontDisp
Set ifontdispLabel = imcgraphobjTemplate.LabelObject.Font
ifontdispLabel.Name = "Courier New"
ifontdispLabel.Size = 20
ifontdispLabel.Bold = True
mdobjsLarge.SetLabelText "%d:Lg", _
mcsltDisplayFeatureIndex + mcsltCopyBorderColor + mcsltLabelTopleft, -1, ifontdispLabel
See Also