⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matrixobj.cpp

📁 图像处理的压缩算法
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*--------------------------------------------------------------------------*
 * File Name:	matrixObj.cpp												*
 * Purpose:		Demonstrate how to access an Origin matrix					*
 * Creation:	March 24, 2000												*
 * Copyright Microcal Software Inc. 2000									*
 *																			*
 * Modification Log:														*
 *	CPY v6.0297 t8155 7/5/00 FASTER_DATASET_ACCESS_FROM_MOCA				*
 *--------------------------------------------------------------------------*/      


#include "matrixObj.h"

//---------------------------------------------------------------------------
// MOCA_ENTRY_POINT( <main object class> )
//
// The MOCA_ENTRY_POINT macro is used to define the exported function that
// Origin will use to communicate with your DLL.  The macro takes a single
// argument, the class name of your main object.
//---------------------------------------------------------------------------
MOCA_ENTRY_POINT(CMatrixDemo)


//---------------------------------------------------------------------------
// Property Map:
//
// The Property Map is for declaring the properties of your LabTalk object.
//
// A property is mapped to Get and Set function.  These functions allow
// you to do error checking or any necessary conversions.  A read-only
// property can be declared by using the _GET macro.
//
// MOCA_PROP_INT( <GetFunction>,<SetFunction>,<PropertyNameStr> )
// MOCA_PROP_REAL( <GetFunction>,<SetFunction>,<PropertyNameStr> )
// MOCA_PROP_STR( <GetFunction>,<SetFunction>,<PropertyNameStr> )
// MOCA_PROP_INT_GET( <GetFunction>,<PropertyNameStr> )
// MOCA_PROP_REAL_GET( <GetFunction>,<PropertyNameStr> )
// MOCA_PROP_STR_GET( <GetFunction>,<PropertyNameStr> )
//
// A Simple Property is mapped to a data member.  There are no Get/Set
// functions for a Simple Property.  MOCA will take care of the assignment.
// A simple read-only property can be declared by using the _GET macro.
//
// MOCA_SIMPLE_PROP_INT( <DataMember>,<PropertyNameStr> )
// MOCA_SIMPLE_PROP_REAL( <DataMember>,<PropertyNameStr> )
// MOCA_SIMPLE_PROP_STR( <DataMember>,<PropertyNameStr> )
// MOCA_SIMPLE_PROP_INT_GET( <DataMember>,<PropertyNameStr> )
// MOCA_SIMPLE_PROP_REAL_GET( <DataMember>,<PropertyNameStr> )
// MOCA_SIMPLE_PROP_STR_GET( <DataMember>,<PropertyNameStr> )
//---------------------------------------------------------------------------
MOCA_BEGIN_PROP_MAP(CMatrixDemo, CMOCAObjBase)
	MOCA_SIMPLE_PROP_STR(m_MatrixName, "MatrixName")
	MOCA_PROP_INT(GetDataType, SetDataType, "DataType")
	MOCA_PROP_INT_GET(GetNumColumns, "NumColumns")
	MOCA_PROP_INT_GET(GetNumRows, "NumRows")
	MOCA_PROP_REAL_GET(GetXMin, "XMin")
	MOCA_PROP_REAL_GET(GetXMax, "XMax")
	MOCA_PROP_REAL_GET(GetYMin, "YMin")
	MOCA_PROP_REAL_GET(GetYMax, "YMax")
MOCA_END_PROP_MAP(CMatrixDemo, CMOCAObjBase)


//---------------------------------------------------------------------------
// Method Map:
//
// INPORTANT: To have a Method Map or a SubObject Map, you must
// have a property map.  A property map can be empty.
//
// MOCA_METH_ENTRY( <MemberFunction>,<MethodNameStr> )
//
// <MemberFunction> must be declared as "BOOL foo(double &, CStringArray &);"
// The double is used for storing LabTalk's return value.
// The CStringArray contains the arguments passed from LabTalk.
//---------------------------------------------------------------------------
MOCA_BEGIN_METH_MAP(CMatrixDemo, CMOCAObjBase)
	MOCA_METH_ENTRY(MethodGetValue, "GetValue")	
	MOCA_METH_ENTRY(MethodSetValue, "SetValue")	
	MOCA_METH_ENTRY(MethodGetRows, "GetRows")	
	MOCA_METH_ENTRY(MethodGetColumns, "GetColumns")	
	MOCA_METH_ENTRY(MethodSetDims, "SetDims")	
	MOCA_METH_ENTRY(MethodSetXY, "SetXY")
	MOCA_METH_ENTRY(MethodFillValues, "Fill")
MOCA_END_METH_MAP(CMatrixDemo, CMOCAObjBase)


//---------------------------------------------------------------------------
// SubObject Map:
//
// IMPORTANT: To have a Method Map or a SubObject Map, you must
// have a property map.  A property map can be empty.
//
// MOCA_SUBOBJ_ENTRY( <m_SubObject>,<SubObjectNameStr> )
//
//---------------------------------------------------------------------------
// This MOCA example has no subobjects.
// The following is an example of how a SubObject table is declared.
//MOCA_BEGIN_SUBOBJ_MAP(CLASSNAME, BASECLASSNAME)
//	MOCA_SUBOBJ_ENTRY(m_SubObject, "SUBOBJECT")
// 	MOCA_SUBOBJ_ENTRY(m_SubObject2, "SUBOBJECT2")
//MOCA_END_SUBOBJ_MAP(CLASSNAME, BASECLASSNAME)


//---------------------------------------------------------------------------
// CMatrixDemo constructors and deconstructors
//---------------------------------------------------------------------------
CMatrixDemo::CMatrixDemo()
{
	m_MatrixName = "Matrix1";
}

CMatrixDemo::~CMatrixDemo()
{
}

//---------------------------------------------------------------------------
// CMatrixDemo::GetDataType
//
// LabTalk Property: DATATYPE
//---------------------------------------------------------------------------
BOOL CMatrixDemo::GetDataType(int &iValue)
{
	iValue = -1; // -1 indicates invalid data type

	// Create a MoMatrix object for the matrix specified in m_MatrixName.
	// A MoMatrix object should be created on stack and should not be kept
	// around between calls, since the matrix may change by the time a
	// second call is made.
	MoMatrix myMatrix(m_MatrixName);		

	// Check if this object is associated with a valid matrix in Origin.
	if( !myMatrix.IsValid() )
		return FALSE; // LabTalk command error

	// Get the matrix's data type
	iValue = myMatrix.GetInternalDataType();

	return TRUE; // LabTalk command succeeded
}

//---------------------------------------------------------------------------
// CMatrixDemo::SetDataType
//
// LabTalk Property: DATATYPE
//---------------------------------------------------------------------------
BOOL CMatrixDemo::SetDataType(int iValue)
{
	// Create a MoMatrix object for the matrix specified in m_MatrixName.
	MoMatrix myMatrix(m_MatrixName);
	if( !myMatrix.IsValid() )
		return FALSE; // LabTalk command error

	// Set the matrix's data type
	if( myMatrix.SetInternalDataType(iValue) == -1 )
		return FALSE; // LabTalk command error

	return TRUE; // LabTalk command succeeded
}

//---------------------------------------------------------------------------
// CMatrixDemo::GetNumColumns
//
// LabTalk Property: NUMCOLUMNS
//---------------------------------------------------------------------------
BOOL CMatrixDemo::GetNumColumns(int &iValue)
{
	iValue = 0;

	// Create a MoMatrix object for the matrix specified in m_MatrixName.
	MoMatrix myMatrix(m_MatrixName);
	if( !myMatrix.IsValid() )
		return FALSE; // LabTalk command error

	// Get the number of columns
	iValue = myMatrix.nCols();   
	
	return TRUE; // LabTalk command succeeded
}

//---------------------------------------------------------------------------
// CMatrixDemo::GetNumRows
//
// LabTalk Property: NUMROWS
//---------------------------------------------------------------------------
BOOL CMatrixDemo::GetNumRows(int &iValue)
{
	iValue = 0;

	// Create a MoMatrix object for the matrix specified in m_MatrixName.
	MoMatrix myMatrix(m_MatrixName);
	if( !myMatrix.IsValid() )
		return FALSE; // LabTalk command error

	// Get the number of columns
	iValue = myMatrix.nRows();   
	
	return TRUE; // LabTalk command succeeded
}

//---------------------------------------------------------------------------
// CMatrixDemo::GetXMin
//
// LabTalk Property: XMIN
//---------------------------------------------------------------------------
BOOL CMatrixDemo::GetXMin(double &dValue)
{
	dValue = NANUM;

	// Create a MoMatrix object for the matrix specified in m_MatrixName.
	MoMatrix myMatrix(m_MatrixName);
	if( !myMatrix.IsValid() )
		return FALSE; // LabTalk command error

	double dXYMaxMin[4];
	myMatrix.GetMatrixXY(dXYMaxMin);
	dValue = dXYMaxMin[0]; // XMin is the first element

	return TRUE; // LabTalk command succeeded
}

//---------------------------------------------------------------------------
// CMatrixDemo::GetXMax
//
// LabTalk Property: XMAX
//---------------------------------------------------------------------------
BOOL CMatrixDemo::GetXMax(double &dValue)
{
	dValue = NANUM;

	// Create a MoMatrix object for the matrix specified in m_MatrixName.
	MoMatrix myMatrix(m_MatrixName);
	if( !myMatrix.IsValid() )
		return FALSE; // LabTalk command error

	double dXYMaxMin[4];
	myMatrix.GetMatrixXY(dXYMaxMin);
	dValue = dXYMaxMin[2]; // XMax is the third element

	return TRUE; // LabTalk command succeeded
}

//---------------------------------------------------------------------------
// CMatrixDemo::GetYMin
//
// LabTalk Property: YMIN
//---------------------------------------------------------------------------
BOOL CMatrixDemo::GetYMin(double &dValue)
{
	dValue = NANUM;

	// Create a MoMatrix object for the matrix specified in m_MatrixName.
	MoMatrix myMatrix(m_MatrixName);
	if( !myMatrix.IsValid() )
		return FALSE; // LabTalk command error

	double dXYMaxMin[4];
	myMatrix.GetMatrixXY(dXYMaxMin);
	dValue = dXYMaxMin[1]; // YMin is the second element

	return TRUE; // LabTalk command succeeded
}

//---------------------------------------------------------------------------
// CMatrixDemo::GetYMax
//
// LabTalk Property: YMAX
//---------------------------------------------------------------------------
BOOL CMatrixDemo::GetYMax(double &dValue)
{
	dValue = NANUM;

	// Create a MoMatrix object for the matrix specified in m_MatrixName.
	MoMatrix myMatrix(m_MatrixName);
	if( !myMatrix.IsValid() )

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -