LAnnRuler::SetUnit
#include "ltwrappr.h"
virtual L_INT LAnnRuler::SetUnit(uUnit, pUnitAbbrev, uPrecision, uFlags=0)
L_UINT uUnit; |
/* unit of measure */ |
L_TCHAR * pUnitAbbrev; |
/* character string containing the unit abbreviation string */ |
L_UINT uPrecision; |
/* number of digits to be displayed after the decimal place */ |
L_UINT uFlags; |
/* flags that determine the object to process */ |
Sets the unit of measurement for the rulers used by those objects that use rulers.
Parameter |
Description |
|
uUnit |
The unit of measure of the ruler. Possible values are: |
|
|
Value |
Meaning |
|
ANNUNIT_INCH |
[0x0000] inches |
|
ANNUNIT_FEET |
[0x0001] feet |
|
ANNUNIT_YARDS |
[0x0002] yards |
|
ANNUNIT_MICROMETERS |
[0x0003] micrometers |
|
ANNUNIT_MILLIMETERS |
[0x0004] millimeters |
|
ANNUNIT_CENTIMETERS |
[0x0005] centimeters |
|
ANNUNIT_METERS |
[0x0006] meters |
|
ANNUNIT_TWIPS |
[0x0007] twips |
|
ANNUNIT_POINTS |
[0x0008] points |
|
ANNUNIT_PIXELS |
[0x0009] pixels |
|
ANNUNIT_SMART_METRIC |
[0x0010] Smart Metric |
|
ANNUNIT_SMART_ENGLISH |
[0x0011] Smart English |
pUnitAbbrev |
Character string containing the unit abbreviation string to be displayed after the distance. You can pass NULL to get the default abbreviations for the current unit of measurement. |
|
uPrecision |
Number of digits to be displayed after the decimal place. |
|
uFlags |
Flags that determine the object to process. You can combine values when appropriate by using a bitwise OR ( | ). The following are valid values: |
|
|
Value |
Meaning |
|
0 |
Process only the specified object. |
|
ANNFLAG_SELECTED |
[0x0001] Process only objects that have the selected property set to TRUE. For getting and setting the selected property, use the LAnnotation::IsSelected and LAnnotation::SetSelected functions. |
|
ANNFLAG_NOINVALIDATE |
[0x0010] Do not invalidate the affected rectangle in the window. Use this to avoid generating unwanted paint messages. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
The following annotation objects utilize one or more rulers as part of the annotation:
ANNOBJECT_CROSSPRODUCT
ANNOBJECT_POLYRULER
ANNOBJECT_PROTRACTOR
ANNOBJECT_RULER
In addition, the Automation object (ANNOBJECT_AUTOMATION) stores default ruler settings along with the other object default settings.
To determine the unit of measure for each ruler as well as its precision, call the LAnnAutomation::GetUnit function or the LAnnRuler::GetUnit function. The default unit of measure for Ruler, Polyruler, and Crossproduct objects is Smart English. With the smart units, the unit changes with the length. For example, if the length is 11 inches (assuming the default precision of 2 is being used), "11.00 in" displays whereas if the length is 15 inches, "1 ft 3.00 in" displays. Call the LAnnAutomation::SetUnit or the LAnnRuler::SetUnit function to set the unit of measurement and its precision for the ruler. The precision indicates how many digits to display to the right of the decimal point in the length.
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. |
See Also
Functions: |
Class Members, LAnnPolyRuler::GetDistance2, ANNSMARTDISTANCE, LAnnotation::CalibrateRuler |
Topics: |
|
|
|
|
|
|
|
|
Example
L_INT LAnnRuler_SetUnitExample(LAnnRuler * pAnnObject) { L_INT nRet; L_SIZE_T uLen; L_UINT uUnit; L_TCHAR * pUnitAbbrev=NULL; L_SIZE_T uPrecision; L_TCHAR buf[180]; L_DOUBLE dDistance; LBuffer LeadBuffer ; /* first, get unit abbreviation string len */ uLen = pAnnObject->GetUnitLen(); LeadBuffer.Reallocate((DWORD)uLen * sizeof(L_TCHAR)) ; pUnitAbbrev = (L_TCHAR *)LeadBuffer.Lock(); /* get the settings */ uUnit = pAnnObject->GetUnit(pUnitAbbrev, &uPrecision,NULL); /* and, get the distance */ nRet = pAnnObject->GetDistance(&dDistance); if(nRet != SUCCESS) return nRet; /* display current settings & distance in current unit of measurement */ wsprintf(buf, TEXT("Unit: %d\nAbbrev: %s\nPrecision: %d\nDistance: %d\n"), uUnit, pUnitAbbrev, uPrecision, dDistance); MessageBox(NULL, buf, TEXT("Units"), MB_OK); /* if unit is not inches, make it so */ if(uUnit != ANNUNIT_INCHES) { nRet = pAnnObject->SetUnit(ANNUNIT_INCHES, TEXT("Inch"), 2, 0); if(nRet != SUCCESS) return nRet; } LeadBuffer.Unlock(); return SUCCESS; }