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

📄 traffic_lump_control.cpp

📁 开发虚拟的被控对象及虚拟的PLC,模似PLC的工作过程进行实验。用户可根据具体的实验,确定其输入和输出的控制条件,用虚拟的连线和虚拟的PLC连接,用户利用梯形图的编程方式编写PLC程序控制被控对象的动
💻 CPP
字号:
#include "StdAfx.h"
#include "PLC_DEMO.h"

#include "PLC_DEMODoc.h"
#include "PLC_DEMOView.h"
#include "Draw_function.h"

bool trafficlumpenable=false;
extern CPLC_DEMOView *fordraw;

void drawround(int,int,int,int,CDC*);

void Traffic_lump_draw()
{
	CDC *thisDC=fordraw->GetDC();
	CPen blackpen(PS_SOLID,1,RGB(0,0,0));
	CPen redpen(PS_SOLID,1,RGB(255,0,0));
	CPen bluepen(PS_SOLID,1,RGB(0,255,0));
	CPen yellowpen(PS_SOLID,1,RGB(255,255,0));
	CBrush blackbrush(RGB(0,0,0));
	CBrush redbrush(RGB(255,0,0));
	CBrush bluebrush(RGB(0,255,0));
	CBrush yellowbrush(RGB(255,255,0));
	CBrush nobrush;
 	nobrush.CreateSysColorBrush(COLOR_3DFACE);
    CPen *oldpen=thisDC->SelectObject(&blackpen);
	CBrush *oldbrush=thisDC->SelectObject(&blackbrush);

	thisDC->SetBkMode(TRANSPARENT);
	
	thisDC->MoveTo(450,60);
	thisDC->LineTo(450,131);
    thisDC->MoveTo(650,60);
	thisDC->LineTo(650,131);
	thisDC->MoveTo(450,440);
	thisDC->LineTo(450,369);
	thisDC->MoveTo(650,440);
	thisDC->LineTo(650,369);

	thisDC->MoveTo(430,150);
	thisDC->LineTo(360,150);
	thisDC->MoveTo(670,150);
	thisDC->LineTo(740,150);
	thisDC->MoveTo(430,350);
	thisDC->LineTo(360,350);
	thisDC->MoveTo(670,350);
	thisDC->LineTo(740,350);

	CPoint p1(430,130);
	CRect r1(p1,p1);
	r1.InflateRect(20,20);
	CPoint p2(450,130);
    CPoint p3(430,150);
	thisDC->Arc(r1,p3,p2);

    CPoint p4(430,370);
	CRect r2(p4,p4);
	r2.InflateRect(20,20);
	CPoint p5(450,370);
    CPoint p6(430,350);
	thisDC->Arc(r2,p5,p6);

	CPoint p7(670,130);
	CRect r3(p7,p7);
	r3.InflateRect(20,20);
	CPoint p8(650,130);
    CPoint p9(670,150);
	thisDC->Arc(r3,p8,p9);
	
	CPoint p10(670,370);
	CRect r4(p10,p10);
	r4.InflateRect(20,20);
	CPoint p11(670,350);
    CPoint p12(650,370);
	thisDC->Arc(r4,p11,p12);//四周

    thisDC->SelectObject(&nobrush);
	drawround(510,145,40,12,thisDC);
	drawround(590,355,40,12,thisDC);
	drawround(445,290,12,40,thisDC);
	drawround(655,210,12,40,thisDC);
	
    thisDC->SelectObject(&blackbrush);

	drawround(490,145,8,8,thisDC);

	thisDC->MoveTo(490,130);
	thisDC->LineTo(490,40);
	thisDC->LineTo(550,40);

	CString writelump;
	writelump.Format("南北黄灯L1");
	thisDC->TextOut(550,32,writelump);

	drawround(510,145,8,8,thisDC);

	thisDC->MoveTo(510,130);
	thisDC->LineTo(510,65);
	thisDC->LineTo(550,65);
	
	writelump.Format("南北绿灯L2");
	thisDC->TextOut(550,57,writelump);

	drawround(530,145,8,8,thisDC);//北

	thisDC->MoveTo(530,130);
	thisDC->LineTo(530,90);
	thisDC->LineTo(550,90);

	writelump.Format("南北红灯L3");
	thisDC->TextOut(550,82,writelump);

	drawround(610,355,8,8,thisDC);
	drawround(590,355,8,8,thisDC);
	drawround(570,355,8,8,thisDC);//南

	drawround(445,310,8,8,thisDC);

	thisDC->MoveTo(427,310);
	thisDC->LineTo(410,310);
	thisDC->MoveTo(427,290);
	thisDC->LineTo(410,290);
	thisDC->MoveTo(427,270);
	thisDC->LineTo(410,270);

	writelump.Format("东西黄灯L4");
	thisDC->TextOut(330,302,writelump);
	writelump.Format("东西绿灯L5");
	thisDC->TextOut(330,282,writelump);
	writelump.Format("东西红灯L6");
	thisDC->TextOut(330,262,writelump);

	thisDC->SelectObject(&blackbrush);
	drawround(330,370,8,8,thisDC);
	drawround(330,392,8,8,thisDC);
	drawround(330,414,8,8,thisDC);
	drawround(330,436,8,8,thisDC);
	drawround(330,458,8,8,thisDC);

	writelump.Format("总开关SBP");
	thisDC->TextOut(340,360,writelump);
	writelump.Format("开关k1");
	thisDC->TextOut(340,382,writelump);
	writelump.Format("开关k2");
	thisDC->TextOut(340,405,writelump);
	writelump.Format("开关k3");
	thisDC->TextOut(340,428,writelump);
	writelump.Format("开关k4");
	thisDC->TextOut(340,450,writelump);
	drawround(445,290,8,8,thisDC);
	drawround(445,270,8,8,thisDC);//西
	drawround(655,190,8,8,thisDC);
	drawround(655,210,8,8,thisDC);
	drawround(655,230,8,8,thisDC);//东
	
	thisDC->SelectObject(oldpen);
	thisDC->SelectObject(oldbrush);
	fordraw->ReleaseDC(thisDC);
}

⌨️ 快捷键说明

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