CMeasureLines:Add


The Add method adds a line marker to the image and reports measurements of its length and angle from the positive x-axis. The Line Measurement toolbar is opened if not already open. See the toolbar description in the Mira User's Guide.

Syntax

bSuccess = CMeasureLines:Add( Image_obj, x1, y1, x2, y2 )

bullet.gif    where Image_obj is a CImage object.

bullet.gif    x1 and y1 are the coordinates of the first point.

bullet.gif    x2 and y2 are the coordinates of the second point.

bullet.gif    On success, bSuccess is returned as true.

Example

Suppose a CImage object I exists. The following script creates a new CMeasureLines object and measures its length and angle. The passed coordinates for both ends of the line are updated to the local centroid positions by setting properties in the LineParams table.

L = new_measurelines()

-- create a new CMeasureLines object

 

 

Params =

 -- LineParams properties to change

{

  

  bSetColor = true,

 

  sColor = "0,255,0",

 

  bSetLineThk = true,

 

  nLineThk = 1.5,

 

  bSetCentroid = true,

-- centroid the first point

  bCentroid = true,

-- centroid the first point

  bSetCentroidEndpt = true,

-- centroid the second point

  bCentroidEndpt = true,

-- centroid the second point

}

  

L:SetParams(Params)

  

 

 

V = attachlist_imageview()

-- connect to an image window

Assert( V, "No image window")

 -- exit if no image window

-- grab an image from the window, V

 

if V:Count() > 1 then

  

  I = CImage:AttachFromList( V )

-- pick the image from CImageView V

  Assert( I, "No Images available")

 -- exit if no image

else

 

  I = V:GetImage()

-- pick the only image in the window

end

 

x1 = 300; y1 = 205

-- initial coordinates of first point

x2 = 100; y2 = 530

-- initial coordinates of second point

bSuccess = L:Add( I, x1, y1, x2, y2 )

-- Add the measurement to the image

Related Topics

CMeasureLines class, LineParams Table

 


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.