DataPlot::GetAxesScaleOverlap

Description

Get XY scale range of data plot related to the layer's XY scale range.

Syntax

int GetAxesScaleOverlap( double * pfX, double * pfY, DWORD dwCntrl = 0 )

Parameters

pfX
[output] fraction of X overlap between data and layer. 1 = exact match, < 1 to indicate layer scale range is bigger then data range, > 1 if data range is bigger and some data outside layer.
pfY
[output] fraction of Y overlap, with similar meaning as pfX.
dwCntrl

Return

< 0 means various error conditions like GORR_DATA_ZERO_WIDTH and

GORR_DATA_ZERO_HEIGHT;

GORR_NO_OVERLAP data plot range does not intersect with layer axes scale range;

GORR_OVERLAPPED data plot range has at least a portion inside the layer axes scale range.

Examples

EX1

// For this example to run, a graph window must exist in the project.
// Then manually add some data to the graph and use the Axes dialog to rescale
// the axes limits so that all the data is un-visible. The example will check if the 
// dataplot require rescale.
void    DataPlot_GetAxesScaleOverlap_ex1()
{
    // the graph layer needs to be initialized:
    GraphLayer        lay = Project.ActiveLayer();

    // the active dataplot is needed for checking
    DataPlot dp = lay.DataPlots(-1);
    if(!dp.IsValid())
        return;
        
    double dfx, dfy;
    bool bNeedRescale = false;
    int nRet = dp.GetAxesScaleOverlap(&dfx, &dfy);
    if ( nRet < 0 )
    {
        bNeedRescale = false;
        error_report("error code:", nRet);
    }
    if ( GORR_NO_OVERLAP == nRet )
        bNeedRescale = true;
    
    // Rescale the layer axes if necessary
    if(bNeedRescale)
        lay.Rescale();
}

Remark

See Also

header to Include

origin.h