Layer::WorldToPage

Description

Converts the world (i.e. axis scale) coordinates into the page (i.e. paper, logical) coordinates.

Syntax

BOOL WorldToPage( int & nXPage, int & nYPage, double rXWorld, double rYWorld )

Parameters

nXPage
[output]the result X page coordinate
nYPage
[output]the result Y page coordinate
rXWorld
the X world coordinate
rYWorld
the Y world coordinate

Return

TRUE if success, otherwise FALSE.

Examples

EX1

//Create a rectangle object and set it's size according to page coordinates.
void Layer_WorldToPage_ex1()
{
    GraphPage gp;
    gp.Create();
    GraphLayer gl = gp.Layers(0);
    
    double xmin = gl.X.From;
    double xmax = gl.X.To;
    double ymin = gl.Y.From;
    double ymax = gl.Y.To;
    
    int nLeft, nRight, nTop, nBottom;
    gl.WorldToPage(nLeft, nTop, xmin, ymax);    
    gl.WorldToPage(nRight, nBottom, xmax, ymin);
    
    GraphObject goRect = gl.CreateGraphObject(GROT_RECT);
    
    // when newly created, somehow need to set Left/Top first, and then set width/height, then later to set Left/Top to
    // properly to set its Rect
    goRect.Left = nLeft;
    goRect.Top = nTop;
    goRect.Width = nRight - nLeft;
    goRect.Height = nBottom - nTop;
    goRect.Top = nTop;
    goRect.Left = nLeft;

    gp.Refresh();    
}

Remark

See Also

Layer::PageToWorld

header to Include

origin.h