2.2.3.8.22 Matrix::SetZRangeUpdate

Description

Enable or disable the automatic dynamic range (Z) update when Matrix data is changed.

Syntax

void SetZRangeUpdate( BOOL bSet = TRUE )

Parameters

bSet
[input] TRUE (default) performs update when class deconstructor is called, FALSE will disable update

Return

Examples

EX1

// Demonstrate the performance difference between Auto Z Range Updating ON and OFF
void Matrix_SetZRangeUpdate_ex1()
{
    DWORD timer1;
    
    MatrixPage MatPg1;
    MatPg1.Create("Origin");
    MatrixLayer MatLy1 = MatPg1.Layers();
    
    fillMatrixData(MatLy1); // Set the gradation from black at leftmost to white at rightmost
    
    timer1 = GetTickCount();
    doTranspose(MatLy1, FALSE); // Make the gradation from top black to bottom white
    printf("Auto Z Range Update:OFF => Transpose took %d ms\n",GetTickCount()-timer1);
    
    timer1 = GetTickCount();
    doTranspose(MatLy1, TRUE); // Recover the original gradation from left black to right white
    printf("Auto Z Range Update:ON => Transpose took %d ms\n",GetTickCount()-timer1);
    
}
void fillMatrixData(MatrixLayer &MatLy1)
{
    int ii,jj;
    
    matrix mat1;
    int wNumRows = 600, wNumCols = 600;
    vector vTemp;
    vTemp.Data(1, wNumCols);   // // Generate (1,2,...,wNumCols) in this temp vector
    mat1.SetSize( wNumRows, wNumCols );  // Set the number of rows and columns in matrix
    for(ii=0; ii<wNumRows; ii++)
        mat1.SetRow(vTemp, ii);  

    Matrix Mat1(MatLy1);
    Mat1 = mat1;
    MatLy1.SetViewImage();  // Set the view of the matrix to the Image Mode. This line is required.
    printf("%dx%d %s is created in Image Mode.\n",wNumRows,wNumCols,Mat1.GetName());
}
void doTranspose(MatrixLayer &MatLy1, BOOL bZRangeScan)
{            
    Matrix Mat1(MatLy1);
    Mat1.SetZRangeUpdate(bZRangeScan); // Turn ON/OFF automatic Z range scanning
    Mat1.Transpose();
}

Remark

Enable (default) or disable the automatic dynamic range (Z range) update when Matrix data is changed. Each Matrix keeps track of the range of the data in the Matrix. Whenever data in the Matrix is changed the internal cache of the dynamic range should be recalculated. Since this recalculation needs to scan the entire matrix the operation can be time consuming. There are some situations when the Origin C programmer can determine that the data range in the matrix will not be changed after an operation on the matrix and thus there is no need to do the rescanning. The performance difference will be effective only if matrix is in ImageView mode.

See Also

Matrix::SetZRange, Matrix::GetZRange

Header to Include

origin.h