编辑: yyy888555 | 2019-07-15 |
要求实现如下功能: 1)按A键,主动块向左运动,带动从动块上下运动,按D键,主动块向右运动,带动从动块上下运动;
2)窗口大小改变时,图形应保持画在客户区的中部;
3)对连杆中点进行轨迹分析(通过菜单启动和关闭分析功能);
实验方案: (1)按键A (或D),使平移量减小(或增加),依据平移量计算各个多边形顶点数, 据依据多边形数据画图. (2)绘制轨迹:点击菜单,启动定时器绘制轨迹. 实验结果和数据处理: class?CHK_772Doc?:?public?CDocument { protected:?//?create?from?serialization?only CHK_772Doc();
DECLARE_DYNCREATE(CHK_772Doc) //?Attributes public: //?Operations public: //?Overrides //?ClassWizard?generated?virtual?function?overrides //{{AFX_VIRTUAL(CHK_772Doc) public: virtual?BOOL?OnNewDocument();
virtual?void?Serialize(CArchive&
?ar);
//}}AFX_VIRTUAL //?Implementation public: void?CalPosition();
double?dX;
?????? double?L,W;
????? double?L1,W1;
??? double?L2,W2;
???? CPoint?Gui1[4];
?? CPoint?Gui2[4];
?? CPoint?Kuai1[4];
? CPoint?Kuai2[4];
CPoint?Origin;
?? CPoint?Gan[4];
???? CPoint?Yuan1[2];
CPoint?Yuan2[2];
CPoint?Guiji;
virtual?~CHK_772Doc();
#ifdef?_DEBUG virtual?void?AssertValid()?const;
class?CHK_772View?:?public?CView { protected:?//?create?from?serialization?only CHK_772View();
DECLARE_DYNCREATE(CHK_772View) //?Attributes public: CHK_772Doc*?GetDocument();
//?Operations public: //?Overrides //?ClassWizard?generated?virtual?function?overrides //{{AFX_VIRTUAL(CHK_772View) public: virtual?void?OnDraw(CDC*?pDC);
??//?overridden?to?draw?this?view virtual?BOOL?PreCreateWindow(CREATESTRUCT&
?cs);
protected: virtual?BOOL?OnPreparePrinting(CPrintInfo*?pInfo);
virtual?void?OnBeginPrinting(CDC*?pDC,?CPrintInfo*?pInfo);
virtual?void?OnEndPrinting(CDC*?pDC,?CPrintInfo*?pInfo);
//}}AFX_VIRTUAL //?Implementation public: CPoint?GuiJi[100];
int?i;
int?middle;
int?keydown;
int?number;
virtual?~CHK_772View();
#ifdef?_DEBUG virtual?void?AssertValid()?const;
virtual?void?Dump(CDumpContext&
?dc)?const;
#endif protected: //?Generated?message?map?functions protected: //{{AFX_MSG(CHK_772View) afx_msg?void?OnKeyDown(UINT?nChar,?UINT?nRepCnt,?UINT?nFlags);
afx_msg?void?OnOpen();
afx_msg?void?OnClose();
afx_msg?void?OnTimer(UINT?nIDEvent);
//}}AFX_MSG DECLARE_MESSAGE_MAP() };
CHK_772View::CHK_772View() { // TODO: add construction code here middle=-1;
} CHK_772View::~CHK_772View() { } BOOL CHK_772View::PreCreateWindow(CREATESTRUCT&
cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs);
} // CHK_772View drawing void CHK_772View::OnDraw(CDC* pDC) { CPen penThick, *oldpen;
CHK_772Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here //先确定参考原点的位置 CRect recClient;
GetClientRect(&
recClient);