MatrixObject::Attach
Attach
Description
It initializes the MatrixObject from the name of a dataset. The dataset must be attached to a matrix, or this initialization will produce invalid MatrixObject.
Attach matrix object on one Worksheet. This method is used to construct a virtual matrix from one Worksheet window. For the virtual matrix, X, Y data can get from one row or one column of the Worksheet, and Z data can get form one data range from the Worksheet.
It initializes the MatrixObject from the MatrixLayer and Index of one of the MatrixLayer. The dataset must be attached to a matrix, or this initialization will produce invalid MatrixObject.
It initializes the MatrixObject from the MatrixLayer' name and Index of one of the MatrixLayer. The dataset must be attached to a matrix, or this initialization will produce invalid MatrixObject.
Syntax
BOOL Attach( LPCSTR lpcszDatasetName )
BOOL Attach(DataRange& rg, DWORD dwCntrl = 0)
BOOL Attach(MatrixLayer &mlayer, UINT nObjectIndex)
BOOL Attach(LPCTSTR MatrixName, UINT nObjectIndex)
Parameters
- lpcszDatasetName
- [input] the name of a dataset.
- rg
- [input] the XYZ data range
- dwCntrl
- [input] value can be 0 or MATOBJATTACH_TRANSPOSE. MATOBJATTACH_TRANSPOSE is used to transpose z values.
- mlayer
- [input] matrix layer attaches to.
- nObjectIndex
- [input] Index of one of the matrix layers in the MatrixLayer
- MatrixName
- [input] name of the MatrixLayer.
- nObjectIndex
- [input] Index of one of the matrix layers in the MatrixLayer
Return
TRUE on success and FALSE on failure.
TRUE on success and FALSE on failure.
TRUE on success and FALSE on failure.
TRUE on success and FALSE on failure.
Examples
EX1
void MatrixObject_Attach_Ex1()
{
MatrixObject mobj;
if (!mobj.Attach("MBook1"))
{
out_str("Attachment failed!");
}
}
EX2
// Before running please new a Worksheet window and import
// Samples\Matrix Conversion and Gridding\XYZ Random Gaussian.dat.
void MatrixObject_Attach_Ex2()
{
Worksheet wks = Project.ActiveLayer();
int r1, r2;
int c1 = 0, c2 = 2;
wks.GetBounds(r1, c1, r2, c2);
// construct a data range object only with Z data, X and Y data will be auto
// assigned.
DataRange dr;
dr.Add("Z", wks, r1, c1, r2, c2);
MatrixObject mo;
mo.Attach(dr, MATOBJATTACH_TRANSPOSE);
double x1, x2, y1, y2;
mo.GetXY(x1, y1, x2, y2);
printf("matrix XY: x = (%g, %g), y = (%g, %g)\n", x1,x2, y1, y2);
GraphPage gp;
gp.Create("CONTOUR");
GraphLayer gl = gp.Layers(0);
gl.AddPlot(mo, IDM_PLOT_CONTOUR);
gl.Rescale();
mo.Detach();
}
EX3
void MatrixObject_Attach_Ex3()
{
MatrixPage mp = Project.MatrixPages(0);
if(!mp)
return;
MatrixLayer ml(mp.GetName());
MatrixObject mObj;
mObj.Attach(ml,0);
}
EX4
void MatrixObject_Attach_Ex4()
{
MatrixPage mp = Project.MatrixPages(0);
if(!mp)
return;
MatrixObject mObj;
mObj.Attach(mp.GetName(), 0);
}
Remark
See Also
Datasheet::Attach, Column::Attach, DataRange::Add, GraphLayer::AddPlot
header to Include
origin.h
|