L_AnnAdjustPoint
#include "l_bitmap.h"
L_INT EXT_FUNCTION L_AnnAdjustPoint(pptAnchor, pptMove, dAngle, nType)
pANNPOINT pptAnchor; |
/* pointer to an ANNPOINT structure that contains the anchor point */ |
pANNPOINT pptMove; |
/* pointer to an ANNPOINT structure that contains the point to be adjusted */ |
L_DOUBLE dAngle; |
/* angle of rotation */ |
L_INT nType; |
/* type of adjustment to point */ |
Modifies the point pptMove based on the angle from line (pptAnchor, pptMove) and the horizontal. This function is available in the Document/Medical Toolkits.
Parameter |
Description |
|
pptAnchor |
Pointer to an ANNPOINT structure representing the anchor point. |
|
pptMove |
Pointer to an ANNPOINT structure representing the point to be adjusted |
|
dAngle |
Angle of rotation in radians. Ranges from -Pi to Pi, (-3.1415… - 3.1415…) where a positive angle corresponds to clockwise rotation. |
|
nType |
Type of adjustment to point. Possible values are: |
|
|
ANNADJUST_HORIZONTAL |
[1] |
|
ANNADJUST_VERITCAL |
[2] |
|
ANNADJUST_45_DEGREES_FAVOR_X |
[3] |
|
ANNADJUST_45_DEGREES_FAVOR_Y |
[4] |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
This utility function is used when creating custom annotation objects. It can be used to calculate the horizontal, vertical, or 45 degree component of a rotated annotation object. It can also be used to easily restrict the mouse cursor on rotated annotation objects.
As an example, consider a rectangle that is rotated 35 degrees in the clockwise direction.
The user has clicked on the Anchor point, and moved the mouse to the Move point.
To find the horizontal component of the line that goes from (Anchor, Move), make the following call, and the ptMove point is adjusted to contain only the horizontal component.
The adjusted ptMove can be seen in step 4.
L_AnnAdjustPoint(&ptAnchor, &ptMove, 35*PI/180, ANNADJUST_HORIZONTAL)
Conceptually, the following occurs:
1. |
Initial situation |
2. |
Points and rectangle are rotated 35 degrees counter clockwise |
3. |
Move point is adjusted to contain only the horizontal component |
4. |
Points and rectangle are rotated 35 degrees clockwise to give adjusted Move point. |
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
Windows 95 / 98 / Me, Windows 2000 / XP.
See Also
Example
// This is part of the custom annotations demo (from example1.c)
// This handler gets called when there is a mouse move message on a user handle
// There are four user handles that are processed differently
// HANDLE_ID_VERTICAL_LEFT
// HANDLE_ID_VERTICAL_RIGHT
// These two both restrict the mouse cursor to a line parallel to the top of the rectangle,
// even if the rectangle is rotated
// HANDLE_ID_HORIZONTAL_BOTTOM
// Restricts the mouse cursor to a line parallel to the side of the rectangle,
// even if the rectangle is rotated
// HANDLE_ID_HORIZONTAL_TOP
// Rotates the rectangle around the bottom handle (HANDLE_ID_HORIZONTAL_BOTTOM)
L_VOID Example1_Handle_MouseMove(LPCHILDDATA pData, pANNMOUSEPOS pMousePos)
{
L_DOUBLE dAngle;
ANNPOINT ptAnchor, ptMove;
L_AnnGetRotateAngle(pData->hObjectChange, &dAngle);
ptAnchor.x = pData->pt0.x;
ptAnchor.y = pData->pt0.y;
ptMove.x = pMousePos->pt.x;
ptMove.y = pMousePos->pt.y;
switch (pData->nUserHandleID)
{
case HANDLE_ID_VERTICAL_LEFT:
case HANDLE_ID_VERTICAL_RIGHT:
{
L_DOUBLE dx, dy;
POINT pt;
L_AnnAdjustPoint(&ptAnchor, &ptMove, dAngle, ANNADJUST_HORIZONTAL);
dx = (ptMove.x - ptAnchor.x)/2;
dy = (ptMove.y - ptAnchor.y)/2;
pt = pMousePos->pt;
pt.x = (LONG)(ptAnchor.x + dx);
pt.y = (LONG)(ptAnchor.y + dy);
L_AnnDefine(pData->hObjectChange, &pMousePos->pt, ANNDEFINE_APPEND);
L_AnnDefine(pData->AnnObjectNeighbors[1], &pt, ANNDEFINE_APPEND);
}
break;
case HANDLE_ID_HORIZONTAL_BOTTOM:
L_AnnAdjustPoint(&ptAnchor, &ptMove, dAngle, ANNADJUST_VERTICAL);
L_AnnDefine(pData->hObjectChange, &pMousePos->pt, ANNDEFINE_APPEND);
L_AnnDefine(pData->AnnObjectNeighbors[1], &pMousePos->pt, ANNDEFINE_APPEND);
break;
case HANDLE_ID_HORIZONTAL_TOP:
L_AnnDefine(pData->hObjectChange, &pMousePos->pt, ANNDEFINE_APPEND);
L_AnnDefine(pData->AnnObjectNeighbors[1], &pMousePos->pt, ANNDEFINE_APPEND);
break;
}
pMousePos->fUpdatePos = FALSE;
if (
(pData->nUserHandleID == HANDLE_ID_VERTICAL_LEFT) ||
(pData->nUserHandleID == HANDLE_ID_VERTICAL_RIGHT) ||
(pData->nUserHandleID == HANDLE_ID_HORIZONTAL_TOP) ||
(pData->nUserHandleID == HANDLE_ID_HORIZONTAL_BOTTOM)
)
{
if (ISDIFFERENT(&ptMove,&pMousePos->pt))
{
pMousePos->pt.x = ROUND(ptMove.x);
pMousePos->pt.y = ROUND(ptMove.y);
pMousePos->fUpdatePos = TRUE;
}
}
}