LAnnCrossProduct::GetDistance2

#include "ltwrappr.h"

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

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.

Parameters

L_UINT *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).

pANNSMARTDISTANCE 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.

pANNSMARTDISTANCE 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.

L_UINT uStructSize

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

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

This function works only for the following objects:

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:

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; 
pCrossProduct->GetDistance2(&uCount, NULL, NULL, sizeof(ANNSMARTDISTANCE)); 
pDistance = (pANNSMARTDISTANCE)malloc(uCount * sizeof(ANNSMARTDISTANCE)); 
pCrossProduct->GetDistance2(&uCount, pDistance, &TotalDistance, sizeof(ANNSMARTDISTANCE)); 

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

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

static 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;  
} 
 
static 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 
static 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 LAnnCrossProduct_GetDistance2Example(LAnnCrossProduct * pObject)  
{ 
   L_UINT uCount;  
   L_TCHAR *pszObject;  
   L_UINT uType;  
   L_INT nRet;  
   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);  
      return FAILURE; 
   } 
 
   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 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.