LAnnProtractor::GetDistance2

#include "ltwrappr.h"

virtual L_INT LAnnProtractor::GetDistance2(puCount, pDistance, pTotalDistance, uStructSize)

L_UINT * puCount;

address of variable to be updated

pANNSMARTDISTANCE pDistance;

address of an array of structures

pANNSMARTDISTANCE pTotalDistance;

address of a variable

L_UINT uStructSize;

size of the structure

Gets the length of each ruler that makes up an object, and the total length of all rulers. It works for ANNOBJECT_RULER, ANNOBJECT_PROTRACTOR, ANNOBJECT_CROSSPRODUCT, and ANNOBJECT_POLYRULER annotation objects.

Parameter

Description

puCount

Address of an unsigned integer to be updated with the total number of rulers that make up the object. This indicates the size of the pDistance array (number of total rulers).

pDistance

Pointer to array of ANNSMARTDISTANCE elements. You must allocate an array that is (*puCount) elements in length. Pass NULL if you do not want this information.

pTotalDistance

Address of an ANNSMARTDISTANCE variable. Returns the total length of all rulers that make up the annotation object. Pass NULL if you do not want this information.

uStructSize

Size of the ANNSMARTDISTANCE structure. Use sizeof(ANNSMARTDISTANCE).

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function works only for the following objects:

ANNOBJECT_RULER 
ANNOBJECT_PROTRACTOR 
ANNOBJECT_CROSSPRODUCT 
ANNOBJECT_POLYRULER 
The ANNOBJECT_POLYRULER object is composed of a variable number of rulers. The other ruler objects are composed of a predetermined number of rulers, as follows: 
ANNOBJECT_RULER always has one distance 
ANNOBJECT_PROTRACTOR and ANNOBJECT_CROSSPRODUCT always have two distances 
ANNOBJECT_POLYRULER can have from one to any number of distances 
To use this function with the ANNOBJECT_POLYRULER, call it twice, as shown in the following code excerpt. For the first call, pass NULL for pDistance and pTotalDistance. This returns the total number of rulers that make up the object. Allocate the appropriately sized array, and then call the function again. 
L_UINT uCount;   
pANNSMARTDISTANCE pDistance;   
ANNSMARTDISTANCE TotalDistance;   
pProtractor->GetDistance2(&uCount, NULL, NULL, sizeof(ANNSMARTDISTANCE));   
pDistance = (p ANNSMARTDISTANCE)malloc(uCount * sizeof(ANNSMARTDISTANCE));   
pProtractor->GetDistance2(&uCount,   
pDistance, &TotalDistance, sizeof(ANNSMARTDISTANCE)); 

Required DLLs and Libraries

LTANN

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Win32, x64.

See Also

Functions:

Class Members

Topics:

Annotation Functions: Working with the Toolbar

 

Implementing Annotations

 

Automated User Interface for Annotations

 

Annotation Objects - Default Values

 

Annotation Objects - Automated Features

 

Using Rulers in Annotation Objects

 

Key Annotation Features

 

Calibrating Annotation Ruler Objects

Example

// This sample calls GetDistance2 on the object // It displays the number of rulers and the length of each ruler

L_TCHAR *annGetObjectString(L_UINT uObjectType)  
{ 
 
	L_TCHAR *pszType = TEXT("Unknown"); 
	switch(uObjectType)  
	{ 
		case ANNOBJECT_CONTAINER:  
		pszType = TEXT("ANNOBJECT_CONTAINER"); 
		break;  
 
		case ANNOBJECT_POINTER:  
		pszType = TEXT("ANNOBJECT_POINTER"); 
		break;  
 
		case ANNOBJECT_AUDIO:  
		pszType = TEXT("ANNOBJECT_AUDIO"); 
		break;  
 
		case ANNOBJECT_BUTTON:  
		pszType = TEXT("ANNOBJECT_BUTTON"); 
		break;  
 
		case ANNOBJECT_ELLIPSE:  
		pszType = TEXT("ANNOBJECT_ELLIPSE"); 
		break;  
 
		case ANNOBJECT_FREEHAND:  
		pszType = TEXT("ANNOBJECT_FREEHAND"); 
		break;  
 
		case ANNOBJECT_HILITE:  
		pszType = TEXT("ANNOBJECT_HILITE"); 
		break;  
 
		case ANNOBJECT_HOTSPOT:  
		pszType = TEXT("ANNOBJECT_HOTSPOT"); 
		break;  
 
		case ANNOBJECT_LINE:  
		pszType = TEXT("ANNOBJECT_LINE"); 
		break;  
 
		case ANNOBJECT_NOTE:  
		pszType = TEXT("ANNOBJECT_NOTE"); 
		break;  
 
		case ANNOBJECT_POLYGON:  
		pszType = TEXT("ANNOBJECT_POLYGON"); 
		break;  
 
		case ANNOBJECT_POLYLINE:  
		pszType = TEXT("ANNOBJECT_POLYLINE"); 
		break;  
 
		case ANNOBJECT_RECT:  
		pszType = TEXT("ANNOBJECT_RECT"); 
		break;  
 
		case ANNOBJECT_REDACT:  
		pszType = TEXT("ANNOBJECT_REDACT"); 
		break;  
 
		case ANNOBJECT_STAMP:  
		pszType = TEXT("ANNOBJECT_STAMP"); 
		break;  
 
		case ANNOBJECT_TEXT:  
		pszType = TEXT("ANNOBJECT_TEXT"); 
		break;  
 
		case ANNOBJECT_AUTOMATION:  
		pszType = TEXT("ANNOBJECT_AUTOMATION"); 
		break;  
 
		case ANNOBJECT_RULER:  
		pszType = TEXT("ANNOBJECT_RULER"); 
		break;  
 
		case ANNOBJECT_CROSSPRODUCT:  
		pszType = TEXT("ANNOBJECT_CROSSPRODUCT"); 
		break;  
 
		case ANNOBJECT_POINT:  
		pszType = TEXT("ANNOBJECT_POINT"); 
		break;  
 
		case ANNOBJECT_PROTRACTOR:  
		pszType = TEXT("ANNOBJECT_PROTRACTOR"); 
		break;  
 
		case ANNOBJECT_VIDEO:  
		pszType = TEXT("ANNOBJECT_VIDEO"); 
		break;  
 
		case ANNOBJECT_PUSHPIN:  
		pszType = TEXT("ANNOBJECT_PUSHPIN"); 
		break;  
 
		case ANNOBJECT_FREEHANDHOTSPOT:  
		pszType = TEXT("ANNOBJECT_FREEHANDHOTSPOT"); 
		break;  
 
		case ANNOBJECT_CURVE:  
		pszType = TEXT("ANNOBJECT_CURVE"); 
		break;  
 
		case ANNOBJECT_CURVECLOSED:  
		pszType = TEXT("ANNOBJECT_CURVECLOSED"); 
		break;  
 
		case ANNOBJECT_ENCRYPT:  
		pszType = TEXT("ANNOBJECT_ENCRYPT"); 
		break;  
 
		case ANNOBJECT_TEXTPOINTER:  
		pszType = TEXT("ANNOBJECT_TEXTPOINTER"); 
		break;  
 
		case ANNOBJECT_POLYRULER:  
		pszType = TEXT("ANNOBJECT_POLYRULER"); 
		break;  
	} 
	return pszType;  
} 
 
 
 
L_TCHAR *annGetRulerUnitString(L_UINT uRulerUnit)  
{ 
 
L_TCHAR *pszRulerUnit = TEXT("Unknown"); 
	switch(uRulerUnit)  
	{ 
		case ANNUNIT_INCHES:  
		pszRulerUnit = TEXT("ANNUNIT_INCHES"); 
		break;  
 
		case ANNUNIT_FEET:  
		pszRulerUnit = TEXT("ANNUNIT_FEET"); 
		break;  
 
		case ANNUNIT_YARDS:  
		pszRulerUnit = TEXT("ANNUNIT_YARDS"); 
		break;  
 
		case ANNUNIT_MICROMETERS:  
		pszRulerUnit = TEXT("ANNUNIT_MICROMETERS"); 
		break;  
 
		case ANNUNIT_MILLIMETERS:  
		pszRulerUnit = TEXT("ANNUNIT_MILIMETERS"); 
		break;  
 
		case ANNUNIT_CENTIMETERS:  
		pszRulerUnit = TEXT("ANNUNIT_CENTIMETERS"); 
		break;  
 
		case ANNUNIT_METERS:  
		pszRulerUnit = TEXT("ANNUNIT_METERS"); 
		break;  
 
		case ANNUNIT_TWIPS:  
		pszRulerUnit = TEXT("ANNUNIT_TWIPS"); 
		break;  
 
		case ANNUNIT_POINTS:  
		pszRulerUnit = TEXT("ANNUNIT_POINTS"); 
		break;  
 
		case ANNUNIT_PIXELS:  
		pszRulerUnit = TEXT("ANNUNIT_PIXELS"); 
		break;  
 
		case ANNUNIT_SMART_METRIC:  
		pszRulerUnit = TEXT("ANNUNIT_SMART_METRIC"); 
		break;  
 
		case ANNUNIT_SMART_ENGLISH:  
		pszRulerUnit = TEXT("ANNUNIT_SMART_ENGLISH"); 
		break;  
	} 
	return pszRulerUnit;  
} 
 
 
// Formats a string with smart distance information 
// uLength is the length of the input string 
 
L_VOID annDumpSmartDistance(ANNSMARTDISTANCE sdSmartDistance, L_TCHAR *pszSmartDistance, L_UINT *puLength)  
{ 
 
	L_TCHAR *pszRulerUnit;  
	L_TCHAR *pszSmartUnit;  
	L_TCHAR szMsg[200];  
	L_UINT uLength;  
 
	pszRulerUnit = annGetRulerUnitString(sdSmartDistance.uRulerUnit);  
	pszSmartUnit = annGetRulerUnitString(sdSmartDistance.uSmartUnit);  
 
	wsprintf(szMsg, TEXT("[%-10f] uRulerUnit[%-15s] uSmartUnit[%-15s]\n"), 
	sdSmartDistance.dDistance,  
	pszRulerUnit,  
	pszSmartUnit);  
 
	uLength = lstrlen(szMsg);  
 
	if (pszSmartDistance)  
	{ 
	lstrcpy(pszSmartDistance, szMsg);  
	} 
 
	if (puLength)  
	{ 
	*puLength = uLength;  
	} 
} 
L_INT LAnnProtractor_GetDistance2SampleAnnGetDistanceExample(LAnnProtractor * pObject)  
{ 
	L_INT nRet; 
	L_UINT uCount;  
	L_TCHAR *pszObject;  
	L_UINT uType;  
	L_TCHAR szMsg[500];  
	ANNSMARTDISTANCE sdTotalDistance;  
	pANNSMARTDISTANCE pDistance = NULL;  
 
	uType = pObject->GetType(); 
	pszObject = annGetObjectString(uType);  
	nRet= pObject->GetDistance2(&uCount, NULL, &sdTotalDistance, sizeof(ANNSMARTDISTANCE));  
	if (nRet != SUCCESS)  
	{ 
		wsprintf(szMsg, TEXT("GetDistance2 Failed[%d]: [%d]%10s"), 
		nRet, uType, pszObject);  
		MessageBox(NULL, szMsg, TEXT("Error"), MB_OK);  
		return nRet;  
	} 
 
// We know the number of rulers 
 
	pDistance = (ANNSMARTDISTANCE * )malloc(uCount * sizeof(ANNSMARTDISTANCE));  
  
	if (!pDistance)  
		MessageBox(NULL, TEXT("Not enough memory"), TEXT("Error"), MB_OK);  
 
	nRet = pObject->GetDistance2(&uCount, pDistance, &sdTotalDistance, sizeof(ANNSMARTDISTANCE));  
 
	if (nRet != SUCCESS)  
	{ 
		wsprintf(szMsg, TEXT("GetDistance2 Failed[%d]: [%d]%10s"), 
		nRet, uType, pszObject);  
		MessageBox(NULL, szMsg, TEXT("Error"), MB_OK);  
		return nRet;  
	} 
 
	free(pDistance);  
 
	return SUCCESS; 
} 

Help Version 20.0.2020.4.5
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help