2.2.4.18.8 GraphObject::Rotate


Description

Specify rotation center to the GraphObject and rotate

Syntax

BOOL    Rotate( double dAngle, point * ptCenter, BOOL bUndo = FALSE )

Parameters

dAngle
[input] Rotation angle
ptCenter
[input] a point object to specify rotation center's x y coordinates in pixel
bUndo
[input] set undoable

Return

TRUE for success

Examples

EX1

void rotate_on_center(string name, int degree)
{
    GraphObject gr;
    GraphLayer gl = Project.ActiveLayer();
    if(gl)
    	gr= gl.GraphObjects(name);
    if(gr)
    {
		gr.Rotate(degree, NULL, true);
		gl.GetPage().Refresh();
    }
}

EX2

// new Graph window, add a rectangle object, object name is Rect
// set rotation center to top center and rotation angle 90: rotate_rect_on_top_center(90)
void rotate_rect_on_top_center(int degree)
{
    string strObj = "Rect";
    GraphObject gr;
    GraphLayer gl = Project.ActiveLayer();
    if(gl)
    	gr= gl.GraphObjects(strObj);
    if(gr)
    {
    	fpoint fpt1, fpt2;
    	fpt1.x = gr.X;//center x
    	fpt1.y = gr.Y + gr.DY*0.5;//top y
    	
    	fpt2 = gr.UnitsConvert(fpt1, UNITS_SCALE, UNITS_PIXEL);
		
    	GraphObject_Rotate_ex(strObj, fpt2.x, fpt2.y, degree);
    }
}

void GraphObject_Rotate_ex(string name, int x, int y, int degree)
{
    GraphObject gr;
    GraphLayer gl = Project.ActiveLayer();
    if(gl)
    	gr= gl.GraphObjects(name);
    if(gr)
    {
		point pt(x, y); //specify x, y in pixel
		gr.Rotate(degree, &pt, true);
		gl.GetPage().Refresh();
    }
}

Remark

See Also

Header to Included

origin.h