📄 simsensorview.cpp
字号:
// SimSensorView.cpp : implementation of the CSimSensorView class
//
#include "stdafx.h"
#include "SimSensor.h"
#include "Node.h"
#include "Sink.h"
#include "SimSensorDoc.h"
#include "SimSensorView.h"
#include "MsgCenter.h"
#include "Draw.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CMsgCenter MsgCenter;
extern CDraw Draw;
////////////////////////////////////////////////////////////////////////////
// CSimSensorView
IMPLEMENT_DYNCREATE(CSimSensorView, CView)
BEGIN_MESSAGE_MAP(CSimSensorView, CView)
//{{AFX_MSG_MAP(CSimSensorView)
ON_WM_CLOSE()
ON_WM_CREATE()
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSimSensorView construction/destruction
CSimSensorView::CSimSensorView()
{
// TODO: add construction code here
}
CSimSensorView::~CSimSensorView()
{
}
BOOL CSimSensorView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CSimSensorView drawing
void CSimSensorView::OnDraw(CDC* pDC)
{
CSimSensorDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
LPRECT ViewRect = new RECT;
GetWindowRect(ViewRect);
g_ViewCenterY = (double)(ViewRect->bottom / 2 - ViewRect->top / 2 );
g_ViewCenterX = (double)(ViewRect->right / 2 - ViewRect->left / 2 );
//TRACE( "CenterX:%f,CenterY:%f\n",g_ViewCenterX,g_ViewCenterY);
// TODO: add draw code for native data here
/*int nCount;
nCount=pDoc->m_obArray.GetSize();
for(int i=0;i<nCount;i++)
{
((CGraph*)pDoc->m_obArray.GetAt(i))->Draw(pDC);
}*/
if (g_NodeSet) {
//Invalidate();
Draw.DrawCoordinates(pDC);
Draw.DrawAllNodes(this,pDC);
}
}
/////////////////////////////////////////////////////////////////////////////
// CSimSensorView diagnostics
#ifdef _DEBUG
void CSimSensorView::AssertValid() const
{
CView::AssertValid();
}
void CSimSensorView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CSimSensorDoc* CSimSensorView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSimSensorDoc)));
return (CSimSensorDoc*)m_pDocument;
}
#endif //_DEBUG
void CSimSensorView::OnClose()
{
//CNode::NodeEnd = true;
//CNodeStrain *pStrain;
/*do {
Sleep(5);
EnterCriticalSection(&(MsgCenter.Locked[0][1]));
pStrain = MsgCenter.pNodeStrain[0][1];
LeaveCriticalSection(&(MsgCenter.Locked[0][1]));
}while(pStrain!=NULL);*/
//CSink::SinkEnd = true;
/*do {
Sleep(5);
EnterCriticalSection(&(MsgCenter.Locked[0][0]));
pStrain = MsgCenter.pNodeStrain[0][0];
LeaveCriticalSection(&(MsgCenter.Locked[0][0]));
}while(pStrain!=NULL);*/
CView::OnClose();
}
int CSimSensorView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
SetTimer(1,100,NULL);
return 0;
}
void CSimSensorView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
KillTimer(1);
//OnPaint();
OnDraw(GetDC());
CSimSensorDoc *pDoc = (CSimSensorDoc *)GetDocument();
if ( g_NodeSet )
pDoc->UpdateAllViews(this);
CView::OnTimer(nIDEvent);
SetTimer(1,100,NULL);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -