LAnnotation::Define2

Summary

Specifies the shape when creating or transforming an annotation object. This function specifies one point in the current window each time it is called.

Syntax

#include "ltwrappr.h"

virtual L_INT LAnnotation::Define2(apt, uState)

Parameters

pANNPOINT apt

Pointer to an ANNPOINT structure. The specified point is in container coordinates.

L_UINT uState

State of the process of modifying the annotation object. Possible values are:

Value Meaning
ANNDEFINE_SETANCHORPOINT [13] This is an anchor point. Use this value when rotating an annotation object around a point other than its center. When doing this, call LAnnotation::Define2 with this flag set prior to calling LAnnotation::Define2 with the ANNDEFINE_BEGINROTATE flag set.
ANNDEFINE_BEGINMOVEPOINT [11] This is a starting point, used when moving one point on an annotation object. This can be used to move a single point on any of the following annotation objects:
LAnnLine
LAnnPolyline
LAnnPolygon
LAnnPointer
LAnnFreeHand
LAnnFreeHandHotSpot
LAnnRuler
LAnnCrossProduct
LAnnProtractor
LAnnCurve
LAnnCurveClosed
You can use ANNDEFINE_BEGINMOVEPOINT to perform a simultaneous rotate and resize for the following objects:
(Note that you must set an anchor point prior to using ANNDEFINE_BEGINMOVEPOINT)
LAnnRectangle
LAnnEllipse
LAnnHilite
LAnnRedact
LAnnText
LAnnNote
LAnnStamp
LAnnHotSpot

When doing this, call LAnnotation::Define2 with the ANNDEFINE_SETANCHORPOINT flag set prior to calling LAnnotation::Define2 with the ANNDEFINE_BEGINMOVEPOINT flag set.

Returns

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

Comments

This function is used only with the following states:

ANNDEFINE_SETANCHORPOINT
ANNDEFINE_BEGINMOVEPOINT

If you try to use a uState value other than ANNDEFINE_SETANCHORPOINT or ANNDEFINE_BEGINMOVEPOINT, the function returns ERROR_INV_PARAMETER.

This function is similar to LAnnotation::Define, except that LAnnotaion::Define2 takes a point in container coordinates, whereas LAnnotation::Define takes a point in client coordinates.

Use this function when additional accuracy is required when setting an anchor point, or doing a simultaneous rotate and resize. This function should be used in conjunction with LAnnotation::Define.

As an example, suppose you want to rotate and resize the rectangle around the anchor point aptAnchor by moving the point aptMove, as shown in the following figure:

image\Ann14Doc_2.gif

This can be done by using only LAnnotation::Define, but because LAnnotation::Define takes integral arguments and aptAnchor and aptMove are not integral, the rotate and resize will not be exact.

To solve this and accurately perform simultaneous rotation and resizing, use LAnnotation::Define2 and LAnnotation::Define as follows:

L_VOID ExampleDefine2(LAnnotation *LAnnObject) 
{ 
   ANNPOINT aptAnchor; 
   ANNPOINT aptMove; 
   ANNPOINT ptLocation; 
 
   aptMove.x = 10.2; 
   aptMove.y = 10.5; 
   aptAnchor.x = 10.2; 
   aptAnchor.y = 50.5; 
   ptLocation.x = 10; 
   ptLocation.y = 20; 
   LAnnObject->Define2(&aptAnchor, ANNDEFINE_SETANCHORPOINT); 
   LAnnObject->Define2(&aptMove, ANNDEFINE_BEGINROTATE); 
 
   // One or more ANNDEFINE_APPEND 
   LAnnObject->Define(&ptLocation, ANNDEFINE_APPEND); 
   LAnnObject->Define(&ptLocation, ANNDEFINE_END); 
} 

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

This example uses static variables to simulate user input to
rotate/resize a rectangle around a point on the bottom center line of the rectangle.
Initially the rectangle must not be rotated.

L_INT LAnnotation_Define2Example(LAnnRectangle *pLRect)  
{ 
   L_INT nRet; 
   // Counter for simulating user input 
   static int nCallCount = 0;   
   L_UINT uType;  
   ANNRECT arcRect;  
   ANNPOINT aptAnchor;  // Anchor point in container coordinates 
   ANNPOINT aptMove;    // Move point in container coordinates 
   POINT    ptMove;     // Move point in client coordinates 
   L_DOUBLE dAngle;  
   LAnnContainer LTmpContainer;  
 
   uType = pLRect->GetType(); 
   if (uType != ANNOBJECT_RECT)  
   { 
      MessageBox(NULL, TEXT("Object must be a rectangle"), TEXT("Error"), MB_OK);  
      return FAILURE;  
   } 
 
   nRet = pLRect->GetRotateAngle(&dAngle);  
   if(nRet != SUCCESS) 
      return nRet; 
 
   if (dAngle != 0)  
   { 
      MessageBox(NULL, TEXT("Object must not be rotated"), TEXT("Error"), MB_OK);  
      return FAILURE;  
   } 
   ++nCallCount;  
   switch (nCallCount)  
   { 
   case 1:  
      nRet = pLRect->GetRect(&arcRect, NULL);  
      if(nRet != SUCCESS) 
         return nRet; 
      aptAnchor.x = (arcRect.left + arcRect.right) / 2;  
      aptAnchor.y = arcRect.bottom;  
 
      aptMove.x = (arcRect.left + arcRect.right) / 2;  
      aptMove.y = arcRect.top;  
 
      nRet = pLRect->Define2(&aptAnchor, ANNDEFINE_SETANCHORPOINT);  
      if(nRet != SUCCESS) 
         return nRet; 
      nRet = pLRect->Define2(&aptMove, ANNDEFINE_BEGINMOVEPOINT);  
      if(nRet != SUCCESS) 
         return nRet; 
      MessageBox(NULL, TEXT("Call ExampleAnnDefine2 to complete the rotate/resize"), TEXT(""), MB_OK);  
      break;  
 
   case 2:  
      nRet = pLRect->GetRect(&arcRect, NULL);  
      if(nRet != SUCCESS) 
         return nRet; 
      aptMove.x = arcRect.right;  
      aptMove.y = arcRect.top;  
 
      nRet = pLRect->GetTopContainer(&LTmpContainer);  
      if(nRet != SUCCESS) 
         return nRet; 
      nRet = LTmpContainer.Convert(&ptMove, &aptMove, 1, ANNCONVERT_TO_CLIENT);  
      if(nRet != SUCCESS) 
         return nRet; 
 
      nRet = pLRect->Define(&ptMove, ANNDEFINE_END);  
      if(nRet != SUCCESS) 
         return nRet; 
      nCallCount = 0;  
      MessageBox(NULL, TEXT("Rotate/resize finished!"), TEXT(""), MB_OK);  
      break;  
   } 
   return SUCCESS;  
} 
Help Version 22.0.2023.2.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help