2.2.3.8.23 Matrix::Update

Description

Update an Origin C Matrix object from an Origin matrix or vice-versa.

Syntax

void Update( BOOL bFromOrigin, int mode = REDRAW_REFRESH )

Parameters

bFromOrigin
[input] TRUE updates an Origin C Matrix object from an Origin matrix, FALSE updates an Origin matrix from an Origin C Matrix object
mode
[input] Matrix update mode, used only if bFromOrigin=FALSE. Supported values (enumerated in OC_const.h) are
REDRAW_NONE Perform update
REDRAW_REFRESH Perform a simple refresh of the data
REDRAW_REALTIME_SCOPE Perform real time drawing for the entire range of data.
To see effect in plots, must set dataplots to animate mode.

Return

Examples

EX1

// Demonstrate updating an Origin C Matrix object from an Origin matrix (by LabTalk)
void Matrix_Update_ex1()
{
    
    MatrixPage MatPg1;
    MatPg1.Create("Origin");
    MatrixLayer MatLy1 = MatPg1.Layers(0);
    Matrix Mat1(MatLy1);
    Mat1.SetSize(2,2);
    printf("  >> Original 2x2 Matrix %s is created.\n",Mat1.GetName());
      
    LT_execute("Matrix -ps DIM 3 3"); // Origin (via LabTalk) changes the matrix dimensions to 3x3
    printf("  >> LabTalk command, Matrix -ps has been applied to %s to make the size 3x3.\n",
      Mat1.GetName());
    printf("  BEFORE Update is applied, internally the number of columns is still %d, NOT updated.\n",
      Mat1.GetNumCols());
    
    Mat1.Update(TRUE);                  // Update from Origin
    printf("  AFTER Update is applied, internally the number of columns is now %d, updated.\n",
      Mat1.GetNumCols());
     
    Mat1.SetSize(4,4);
    printf("  >> OC function, SetSize has been applied to %s to make the size 4x4.\n",
      Mat1.GetName());
    printf("  Number of columns is internally already %d even without applying Update.\n",
      Mat1.GetNumCols());
}

EX2

// Demonstrate updating an Origin matrix from an Origin C Matrix object
void Matrix_Update_ex2()
{
    
    PageBase pgbas1;
    pgbas1 = Project.Pages(); // Get the project's active page
    if(pgbas1.GetType()!=EXIST_MATRIX) {
        printf("  Error: No active matrix. Please make an active matrix window.\n");
        return;
    }

    Matrix Mat1(pgbas1.GetName());
    Mat1 = 0; // OC Matrix becomes a zero matrix internally.
    
    MessageBox(GetWindow(),"  Note that Matrix1 becomes a zero matrix internally.");
    Mat1.Update(FALSE,REDRAW_NONE);
    MessageBox(GetWindow(),"  Updated with no refresh. Note that Matrix1 looks unchanged.");
    
    Mat1.Update(FALSE,REDRAW_REFRESH);
    MessageBox(GetWindow(),"  Updated with refresh. Matrix1 has been changed to a zero matrix.");
}

Remark

Update an Origin C Matrix object when the matrix data in Origin is changed or update the matrix in Origin before exiting from the current program scope.

See Also

Dataset::Update

Header to Include

origin.h