LVectorObject::SetRotation
#include "ltwrappr.h"
virtual L_INT LVectorObject::SetRotation(pRotation, pOrigin=NULL)
const pVECTORPOINT pRotation; |
/* pointer to a vector point */ |
const pVECTORPOINT pOrigin; |
/* pointer to a vector point */ |
Rotates the class object. This function is available in the LEADTOOLS Vector Imaging Pro Toolkit.
Parameter |
Description |
pRotation |
Pointer to a VECTORPOINT structure that contains the rotation values for each axis. The rotation values are in degrees. |
pOrigin |
Pointer to a VECTORPOINT structure that contains the center of rotation If pOrigin is NULL, the center of the class object. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
Rotates the class object based on the rotation values in pRotation.
The rotation values may be retrieved using LVectorBase::GetRotation.
Note for DirectX:, You cannot select objects or enumerate them.
Note that rotating an object may change the object type. However, not all object types are changed by rotation, and not all rotations result in changing an object type. For example, a rectangle rotated 90 degrees about the z-axis is still a rectangle. A rectangle rotated 45 degrees about the z-axis becomes a polydraw object. The table below indicates object types that may change following rotation and the possible resulting object types.
Original object type |
Possible object type following rotation |
VECTOR_RECTANGLE |
VECTOR_POLYGON |
VECTOR_ELLIPSE |
VECTOR_POLYDRAW |
VECTOR_CIRCLE |
VECTOR_POLYDRAW |
VECTOR_ARC |
VECTOR_POLYDRAW |
VECTOR_TEXT |
VECTOR_POLYDRAW |
VECTOR_PIE |
VECTOR_POLYDRAW |
If an object type changes, LVectorObject::LockObject and LVectorObject::UnlockObject will return WRPERR_VECTOR_INVALID_OBJECT_TYPE. Object properties can still be inspected and changed by using LVectorObject::GetObjectAttributes and LVectorObject::SetObjectAttributes.
Required DLLs and Libraries
LVKRN 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: |
|
Topics: |
Example
// This example will rotate a vector object under pPoint.
L_VOID Example102(HWND hWnd, LVectorBase *pVector, LPPOINT pPoint)
{
LVectorObject VectorObject;
L_INT nRet;
nRet = pVector->HitTest(pPoint, &VectorObject);
if (nRet==SUCCESS)
{
VECTORPOINT pointRotate;
pointRotate.x = 0;
pointRotate.y = 0;
pointRotate.z = 90;
VectorObject.SetRotation(&pointRotate);
}
}
// This example will add a rectangle to the Active Layer LVectorBase object.
// Once added, the rectangle will be rotated twice.
// Rotating the first time 90 degrees, the object type remains type VECTOR_RECTANGLE.
// Rotating the second time 45 degrees, the object type changes to a VECTOR_POLYDRAW.
L_VOID Example107(HWND hWnd, LVectorBase *pVector)
{
VECTORRECTANGLE Rectangle;
L_INT nRet;
//Create Rectangle Object
Rectangle.Point[0].x = 30;
Rectangle.Point[0].y = 30;
Rectangle.Point[0].z = 10;
Rectangle.Point[1].x = 80;
Rectangle.Point[1].y = 50;
Rectangle.Point[1].z = 10;
Rectangle.Brush.nSize = sizeof(VECTORBRUSH);
Rectangle.Brush.VectorBrushStyle = VECTORBRUSH_STANDARD;
Rectangle.Brush.BrushType.StandardBrush.LogBrush.lbColor = RGB(0,128,0);
Rectangle.Brush.BrushType.StandardBrush.LogBrush.lbStyle = BS_SOLID;
Rectangle.Pen.nSize = sizeof( VECTORPEN );
Rectangle.Pen.bExtPen = FALSE;
Rectangle.Pen.NewPen.LogPen.lopnStyle = PS_SOLID;
Rectangle.Pen.NewPen.LogPen.lopnWidth.x = 2;
Rectangle.Pen.NewPen.LogPen.lopnWidth.y = 2;
Rectangle.Pen.NewPen.LogPen.lopnColor = RGB(255,0,0);
LVectorRectangle VectorRectangle(&Rectangle);
pVector->AddObject(&VectorRectangle);
//Rotate 90 degrees along the Z-Axis--it stays a VECTOR_RECTANGLE
MessageBox(NULL, TEXT("Rotating 90 degrees along the Z-axis"), TEXT(""), MB_OK);
VECTORPOINT pointRotation;
pointRotation.x = 0;
pointRotation.y = 0;
pointRotation.z = 90;
VectorRectangle.SetRotation(&pointRotation);
VECTORRECTANGLE RectangleTemp;
nRet = VectorRectangle.LockObject(&RectangleTemp);
if (nRet == SUCCESS)
{
RectangleTemp.Pen.NewPen.LogPen.lopnColor = RGB(0,0,255);
VectorRectangle.UnlockObject(&RectangleTemp);
}
//Rotate rectangle 45 degrees--it becomes an VECTOR_POLYDRAW object
pointRotation.x = 0;
pointRotation.y = 0;
pointRotation.z = 45;
//Cannot call LockObject/UnlockObject here, but can still change properties
//Object type is still a Rectangle
//Change color with SetObjectAttributes()
VECTORBRUSH brush;
brush.VectorBrushStyle = VECTORBRUSH_STANDARD;
brush.BrushType.StandardBrush.LogBrush.lbColor = RGB(128,128,0);
}