L_AnnGetDistance2

#include "l_bitmap.h"

L_LTANN_API L_INT L_AnnGetDistance2(hObject, puCount, pDistance, pTotalDistance, uStructSize)

HANNOBJECT hObject;

/* handle to the annotation object */

L_UINT *puCount;

/* address of variable to be updated */

pANNSMARTDISTANCE pDistance;

/* address of an array of ANNSMARTDISTANCE structures */

pANNSMARTDISTANCE pTotalDistance;

/* address of an ANNSMARTDISTANCE variable */

L_UINT uStructSize;

/* size of the structure initialize with sizeof(ANNSMARTDISTANCE) */

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

hObject

Handle to the annotation object.

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

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;

   L_AnnGetDistance2(hObject, &uCount, NULL, NULL, sizeof(ANNSMARTDISTANCE));
   pDistance = (pANNSMARTDISTANCE)malloc(uCount * sizeof(ANNSMARTDISTANCE));
   L_AnnGetDistance2(hObject, &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:

L_AnnSetBitmapDpiX, L_AnnGetBitmapDpiX, L_AnnGetBitmapDpiY, L_AnnSetBitmapDpiY, L_AnnGetUnit, L_AnnGetUnitLen, L_AnnGetDistance, L_AnnSetGaugeLength, L_AnnGetGaugeLength, L_AnnSetUnit, ANNSMARTDISTANCE

Topics:

Annotation Functions: Working with the Toolbar

 

Implementing Annotations

 

Automated User Interface for Annotations

 

Annotation Objects - Default Values

 

Annotation Objects - Automated Features

 

Implementing an Automated Annotation Program

 

Implementing a Non-automated Annotation Program

 

Annotation Functions (Document/Medical only): Ruler Properties

 

Annotation Functions (Document/Medical only): Protractor Properties

 

Annotation Functions (Document/Medical only): Polyruler Properties

 

Using Rulers in Annotation Objects

 

Annotation Features

 

Calibrating Annotation Ruler Objects

Example

This sample calls L_AnnDistance2 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_MILLIMETERS");
      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);

   _stprintf_s(szMsg, TEXT("[%-10f] uRulerUnit[%-15s] uSmartUnit[%-15s]\n"),
            sdSmartDistance.dDistance,
            pszRulerUnit,
            pszSmartUnit);

   uLength = lstrlen(szMsg) * sizeof (L_TCHAR);

   if (pszSmartDistance)
   {
      lstrcpy(pszSmartDistance, szMsg);
   }

   if (puLength)
   {
      *puLength = uLength;
   }
}
 L_INT AnnGetDistance2Example(HANNOBJECT hObject)
{
   L_UINT            uCount;
   L_TCHAR*          pszObject;
   L_UINT            uType;
   L_INT             nRet;
   L_TCHAR           szMsg[500];
   ANNSMARTDISTANCE  sdTotalDistance;
   pANNSMARTDISTANCE pDistance = NULL;

   nRet = L_AnnGetType(hObject, &uType);
   if(nRet != SUCCESS)
      return nRet;
   pszObject = annGetObjectString(uType);
   nRet= L_AnnGetDistance2(hObject, &uCount, NULL, &sdTotalDistance, sizeof(ANNSMARTDISTANCE));
   if (nRet != SUCCESS)
   {
      wsprintf(szMsg, TEXT("L_AnnGetDistance2 Failed[%d]: [%d]%10s"),
         nRet, uType, pszObject);
      MessageBox(NULL, szMsg, TEXT("Error"), MB_OK);
      return nRet;
   }
   // We know the number of rulers
   pDistance = (pANNSMARTDISTANCE) malloc(uCount * sizeof(ANNSMARTDISTANCE));
   if (!pDistance)
      MessageBox(NULL, TEXT("Not enough memory"), TEXT("Error"), MB_OK);

   nRet = L_AnnGetDistance2(hObject, &uCount, pDistance, &sdTotalDistance, sizeof(ANNSMARTDISTANCE));
   if (nRet != SUCCESS)
   {
      wsprintf(szMsg, TEXT("L_AnnGetDistance2 Failed[%d]: [%d]%10s"),
         nRet, uType, pszObject);
      MessageBox(NULL, szMsg, TEXT("Error"), MB_OK);
      return nRet;
   }

   free(pDistance);
   return SUCCESS;
}