📄 shenjctl.cpp
字号:
// ShenJCtl.cpp : Implementation of the CShenJCtrl ActiveX Control class.
#include "stdafx.h"
#include "ShenJ.h"
#include "ShenJCtl.h"
#include "ShenJPpg.h"
//#include "mbp1.h"
//#include "mdlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CShenJCtrl, COleControl)
/////////////////////////////////////////////////////////////////////////////
// Message map
BEGIN_MESSAGE_MAP(CShenJCtrl, COleControl)
//{{AFX_MSG_MAP(CShenJCtrl)
// NOTE - ClassWizard will add and remove message map entries
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG_MAP
ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Dispatch map
BEGIN_DISPATCH_MAP(CShenJCtrl, COleControl)
//{{AFX_DISPATCH_MAP(CShenJCtrl)
DISP_FUNCTION(CShenJCtrl, "initdata", initdata, VT_EMPTY, VTS_I2 VTS_I2 VTS_I2 VTS_R8)
DISP_FUNCTION(CShenJCtrl, "runmbp", runmbp, VT_EMPTY, VTS_NONE)
DISP_FUNCTION(CShenJCtrl, "returndata", returndata, VT_R8, VTS_NONE)
DISP_FUNCTION(CShenJCtrl, "getday", getday, VT_EMPTY, VTS_I2)
DISP_FUNCTION(CShenJCtrl, "getvalue", getvalue, VT_EMPTY, VTS_R8)
DISP_FUNCTION(CShenJCtrl, "getvalue1", getvalue1, VT_EMPTY, VTS_R8 VTS_R8 VTS_R8 VTS_R8 VTS_R8)
//}}AFX_DISPATCH_MAP
DISP_FUNCTION_ID(CShenJCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox, VT_EMPTY, VTS_NONE)
END_DISPATCH_MAP()
/////////////////////////////////////////////////////////////////////////////
// Event map
BEGIN_EVENT_MAP(CShenJCtrl, COleControl)
//{{AFX_EVENT_MAP(CShenJCtrl)
// NOTE - ClassWizard will add and remove event map entries
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_EVENT_MAP
END_EVENT_MAP()
/////////////////////////////////////////////////////////////////////////////
// Property pages
// TODO: Add more property pages as needed. Remember to increase the count!
BEGIN_PROPPAGEIDS(CShenJCtrl, 1)
PROPPAGEID(CShenJPropPage::guid)
END_PROPPAGEIDS(CShenJCtrl)
/////////////////////////////////////////////////////////////////////////////
// Initialize class factory and guid
IMPLEMENT_OLECREATE_EX(CShenJCtrl, "SHENJ.ShenJCtrl.1",
0xf5541da6, 0xaca9, 0x11d7, 0x9b, 0x1a, 0x52, 0x54, 0xab, 0x12, 0x97, 0x87)
/////////////////////////////////////////////////////////////////////////////
// Type library ID and version
IMPLEMENT_OLETYPELIB(CShenJCtrl, _tlid, _wVerMajor, _wVerMinor)
/////////////////////////////////////////////////////////////////////////////
// Interface IDs
const IID BASED_CODE IID_DShenJ =
{ 0xf5541da4, 0xaca9, 0x11d7, { 0x9b, 0x1a, 0x52, 0x54, 0xab, 0x12, 0x97, 0x87 } };
const IID BASED_CODE IID_DShenJEvents =
{ 0xf5541da5, 0xaca9, 0x11d7, { 0x9b, 0x1a, 0x52, 0x54, 0xab, 0x12, 0x97, 0x87 } };
/////////////////////////////////////////////////////////////////////////////
// Control type information
static const DWORD BASED_CODE _dwShenJOleMisc =
OLEMISC_ACTIVATEWHENVISIBLE |
OLEMISC_SETCLIENTSITEFIRST |
OLEMISC_INSIDEOUT |
OLEMISC_CANTLINKINSIDE |
OLEMISC_RECOMPOSEONRESIZE;
IMPLEMENT_OLECTLTYPE(CShenJCtrl, IDS_SHENJ, _dwShenJOleMisc)
/////////////////////////////////////////////////////////////////////////////
// CShenJCtrl::CShenJCtrlFactory::UpdateRegistry -
// Adds or removes system registry entries for CShenJCtrl
BOOL CShenJCtrl::CShenJCtrlFactory::UpdateRegistry(BOOL bRegister)
{
// TODO: Verify that your control follows apartment-model threading rules.
// Refer to MFC TechNote 64 for more information.
// If your control does not conform to the apartment-model rules, then
// you must modify the code below, changing the 6th parameter from
// afxRegApartmentThreading to 0.
if (bRegister)
return AfxOleRegisterControlClass(
AfxGetInstanceHandle(),
m_clsid,
m_lpszProgID,
IDS_SHENJ,
IDB_SHENJ,
afxRegApartmentThreading,
_dwShenJOleMisc,
_tlid,
_wVerMajor,
_wVerMinor);
else
return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
}
/////////////////////////////////////////////////////////////////////////////
// CShenJCtrl::CShenJCtrl - Constructor
CShenJCtrl::CShenJCtrl()
{
InitializeIIDs(&IID_DShenJ, &IID_DShenJEvents);
k=0;
k1=0;
// TODO: Initialize your control's instance data here.
}
/////////////////////////////////////////////////////////////////////////////
// CShenJCtrl::~CShenJCtrl - Destructor
CShenJCtrl::~CShenJCtrl()
{
// TODO: Cleanup your control's instance data here.
k=0;
k1=0;
}
/////////////////////////////////////////////////////////////////////////////
// CShenJCtrl::OnDraw - Drawing function
void CShenJCtrl::OnDraw(
CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
// TODO: Replace the following code with your own drawing code.
pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
pdc->Ellipse(rcBounds);
}
/////////////////////////////////////////////////////////////////////////////
// CShenJCtrl::DoPropExchange - Persistence support
void CShenJCtrl::DoPropExchange(CPropExchange* pPX)
{
ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
COleControl::DoPropExchange(pPX);
// TODO: Call PX_ functions for each persistent custom property.
}
/////////////////////////////////////////////////////////////////////////////
// CShenJCtrl::OnResetState - Reset control to default state
void CShenJCtrl::OnResetState()
{
COleControl::OnResetState(); // Resets defaults found in DoPropExchange
// TODO: Reset any other control state here.
}
/////////////////////////////////////////////////////////////////////////////
// CShenJCtrl::AboutBox - Display an "About" box to the user
void CShenJCtrl::AboutBox()
{
CDialog dlgAbout(IDD_ABOUTBOX_SHENJ);
dlgAbout.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
void CShenJCtrl::initdata(short qs1, short cs1, short xx1, double epsl11)
{
// TODO: Add your dispatch handler code here
qs=qs1;
cs=cs1;
xx=xx1;
Epsl=epsl11;
}
void CShenJCtrl::runmbp()
{
// TODO: Add your dispatch handler code here
// days[]={1,2,3,4,5,6};//观测时间序列
CMBP mdata;
for(int i=0;i<=k1;i++)
mdata.v[i]=v1[i];
mdata.PreProcess(qs,cs);
//PreProcess(int qs,int cs)
// 观测值归一化程序
// qs:观测期数
//cs:参数个数
mdata.InitData(qs,cs,days);
//初始化程序
//InitData(int qs,int cs,int *days)
// qs: 观测期数
//cs: 参数个数
// days: 观测时间(以年为单位,并减去起始时间)
mdata.Exercise(mdata,Epsl);
// 训练
// mdata:训练样本
mdata.predict(xx);
rest=mdata.m_result[0];
//预测
//xx:预测时间(以期为单位,起始为0)
//dlg.m_time=xx; //xx :预测期数
//dlg.m_x=mdata.m_result[0];//xx 期对应的地裂缝活动强度
//double tt=mdata.v[(xx-1)*4]; //xx 期已观测的地裂缝活动强度,以提供对比
//dlg.m_z=(tt-0.1)*(mdata.max[0]-mdata.min[0])/0.8+mdata.min[0];//反归一化处理
k=0;
k1=0;
//显示预测结果
//dlg.DoModal();
}
double CShenJCtrl::returndata()
{
// TODO: Add your dispatch handler code here
return rest;
}
void CShenJCtrl::getday(short day1)
{
// TODO: Add your dispatch handler code here
days[k]=day1;
k++;
}
void CShenJCtrl::getvalue(double vd1)
{
// TODO: Add your dispatch handler code here
v1[k1]=vd1;
k1++;
}
void CShenJCtrl::getvalue1(double vd1, double vd2, double vd3, double vd4, double vd5)
{
// TODO: Add your dispatch handler code here
v1[k1]=vd1;
v2[k1]=vd2;
v3[k1]=vd3;
v4[k1]=vd4;
v5[k1]=vd5;
k1++;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -