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

📄 pointtestview.cpp

📁 利用VisualC++写的一个比较大的画电路土软件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// PointtestView.cpp : implementation of the CPointtestView class
//

#include "stdafx.h"
#include "Pointtest.h"

#include "PointtestDoc.h"
#include "PointtestView.h"
#include "selecttool.h"
#include "linetool.h"
#include "pointtool.h"
#include "dottool.h"
#include "captool.h"
#include "indtool.h"
#include "powertool.h"
#include "groundtool.h"
#include "diodetool.h"
#include "switchtool.h"
#include "currenttool.h"
#include "voltagetool.h"
#include "lighttool.h"
#include "texttool.h"
#include "rheostattool.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CPointtestView

IMPLEMENT_DYNCREATE(CPointtestView, CView)

BEGIN_MESSAGE_MAP(CPointtestView, CView)
	//{{AFX_MSG_MAP(CPointtestView)
	ON_COMMAND(ID_SELECTONE, OnSelect)
	ON_COMMAND(ID_DIANZU, OnResistance)
	ON_COMMAND(ID_KETIAODIANZU,OnRheostat)
	ON_COMMAND(ID_DIAN, OnPoint)
	ON_COMMAND(ID_CAP, OnCapacitance)
	ON_COMMAND(ID_ERJIGUAN, OnDiode)
	ON_COMMAND(ID_DI, OnGround)
	ON_COMMAND(ID_DIANGAN, OnInductance)
	ON_COMMAND(ID_DDDZ, OnSwitch)
	ON_COMMAND(ID_DIANYUAN, OnPower)
	ON_COMMAND(ID_DIANYABIAO, OnVoltage)
	ON_COMMAND(ID_DIANLIUBIAO, OnCurrent)
	ON_COMMAND(ID_DENG, OnLight)
	ON_COMMAND(ID_HGRIP, OnHGrip)
	ON_COMMAND(ID_VGRIP, OnVGrip)
	ON_COMMAND(ID_ANTICLOCKWISE, OnAntiClockWise)
	ON_COMMAND(ID_DEAZIL, OnSeaZil)
	ON_COMMAND(ID_GO, OnGogo)
	ON_COMMAND(ID_TEXTA, OnText)
	ON_COMMAND(ID_CALCULATE, OnCalculate)
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONUP()
	ON_WM_MOUSEMOVE()
	ON_WM_CREATE()
	ON_WM_KEYDOWN()
	ON_WM_LBUTTONDBLCLK()
	ON_UPDATE_COMMAND_UI(ID_DIAN, OnUpdateDian)
	ON_UPDATE_COMMAND_UI(ID_DI, OnUpdateDi)
	ON_UPDATE_COMMAND_UI(ID_DENG, OnUpdateDeng)
	ON_UPDATE_COMMAND_UI(ID_DDDZ, OnUpdateDddz)
	ON_UPDATE_COMMAND_UI(ID_CAP, OnUpdateCap)
	ON_UPDATE_COMMAND_UI(ID_DIANZU, OnUpdateDianzu)
	ON_UPDATE_COMMAND_UI(ID_DIANYUAN, OnUpdateDianyuan)
	ON_UPDATE_COMMAND_UI(ID_DIANYABIAO, OnUpdateDianyabiao)
	ON_UPDATE_COMMAND_UI(ID_DIANLIUBIAO, OnUpdateDianliubiao)
	ON_UPDATE_COMMAND_UI(ID_DIANGAN, OnUpdateDiangan)
	ON_UPDATE_COMMAND_UI(ID_ERJIGUAN, OnUpdateErjiguan)
	ON_UPDATE_COMMAND_UI(ID_SELECTONE, OnUpdateSelectone)
	ON_UPDATE_COMMAND_UI(ID_TEXTA, OnUpdateTexta)
	ON_UPDATE_COMMAND_UI(ID_KETIAODIANZU, OnUpdateKetiaodianzu)
	ON_WM_CLOSE()
	ON_COMMAND(ID_LOOKMETER, OnLookmeter)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
	//ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
//	ON_MESSAGE(WM_PLEASECOPY, OnPleaseCopy)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPointtestView construction/destruction
CBitmap blank;
int width,height;
int RisisNumber = 0; //电阻
int PowerNumber = 0; //电源
int CapNumber = 0;   //电容
int DiodeNumber = 0; //二极管
int InduNumber = 0;  //电感
int LightNumber = 0; //灯泡
int GroundNumber = 0;//接地
int CurrentNumber = 0;//电流表
int VoltageNumber = 0;//电压表
int SwitchNumber = 0; //开关
int RheostatNumber = 0;//变阻器

CPointtestView::CPointtestView()
{
	Operation_id = ID_SELECT;
	m_pBaseTool = NULL;
	m_pNodeList = NULL;
	id_Check = ID_SELECTONE;
	
}

CPointtestView::~CPointtestView()
{
	
}

BOOL CPointtestView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CPointtestView drawing

void CPointtestView::OnDraw(CDC* pDC)
{
	CPointtestDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	//DrawCompanySign(pDC, 0,(height/2-100));
	m_pList->Draw(pDC);
	m_pLineList->Draw(pDC);
	m_pTextList->Draw(pDC);
	/*ShowCursor(TRUE);
	ClipCursor( NULL );
	ReleaseCapture();*/
}

/////////////////////////////////////////////////////////////////////////////
// CPointtestView printing

BOOL CPointtestView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CPointtestView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CPointtestView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CPointtestView diagnostics

#ifdef _DEBUG
void CPointtestView::AssertValid() const
{
	CView::AssertValid();
}

void CPointtestView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CPointtestDoc* CPointtestView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CPointtestDoc)));
	return (CPointtestDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CPointtestView message handlers

void CPointtestView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	if( m_pBaseTool )
		m_pBaseTool->OnLButtonDown( nFlags, point );	
	
	CView::OnLButtonDown(nFlags, point);
}

void CPointtestView::OnLButtonUp(UINT nFlags, CPoint point) 
{
	if( m_pBaseTool )
		m_pBaseTool->OnLButtonUp( nFlags, point );	
	
	CView::OnLButtonUp(nFlags, point);
}

void CPointtestView::OnMouseMove(UINT nFlags, CPoint point) 
{
	if( m_pBaseTool )
		m_pBaseTool->OnMouseMove( nFlags, point );	

	CView::OnMouseMove(nFlags, point);
}

int CPointtestView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	return 0;
}

void CPointtestView::OnSelect()//
{
	ToolBox(ID_SELECT);
	id_Check = ID_SELECTONE;
}
void CPointtestView::OnResistance()//
{
	ToolBox(ID_RESISTANCE);
	id_Check = ID_DIANZU;
}
void CPointtestView::OnRheostat()
{
	ToolBox(ID_RHEOSTAT);
	id_Check = ID_KETIAODIANZU;
}
void CPointtestView::OnPoint()//++
{
	ToolBox(ID_DOT);
	id_Check = ID_DIAN;
}
void CPointtestView::OnCapacitance()//
{
	ToolBox(ID_CAPACITANCE);
	id_Check = ID_CAP;
}
void CPointtestView::OnDiode()//
{
	ToolBox(ID_DIODE);
	id_Check = ID_ERJIGUAN;
}
void CPointtestView::OnGround()//++
{
	ToolBox(ID_GROUND);
	id_Check = ID_DI;
}
void CPointtestView::OnInductance()//
{
	ToolBox(ID_INDUCTANCE);
	id_Check = ID_DIANGAN;
}
void CPointtestView::OnVoltage()//
{
	ToolBox(ID_VOLTAGE_METER);
	id_Check = ID_DIANYABIAO;
}
void CPointtestView::OnCurrent()//
{
	ToolBox(ID_CURRENT_METER);
	id_Check = ID_DIANLIUBIAO;
}

void CPointtestView::OnSwitch()//++
{
	ToolBox(ID_SWITCH);
	id_Check = ID_DDDZ;
}
void CPointtestView::OnPower()
{
	ToolBox(ID_POWER);
	id_Check = ID_DIANYUAN;
}
void CPointtestView::OnLight()//++
{
	ToolBox(ID_LIGHT);
	id_Check = ID_DENG;
}
void CPointtestView::OnText()
{
	ToolBox(ID_TEXT);
	id_Check = ID_TEXTA;
}
void CPointtestView::OnCalculate()
{
CWnd* pWnd=CWnd::FindWindow(NULL,"计算器");
	if(pWnd==NULL)
	{
//	if(ShellExecute(NULL,"open","c:\\windows\\calc.exe",NULL,NULL,SW_SHOWNORMAL)<=32);
		if((WinExec("calc.exe",SW_SHOW))<=31)
			AfxMessageBox("找不到calc.exe文件,不能执行此操作!");
	}
	else
	{
		CWnd* pWndPopup=pWnd->GetLastActivePopup();
		pWnd->SetForegroundWindow();
		if(pWnd->IsIconic())
			pWnd->ShowWindow(SW_SHOWNORMAL);
		if(pWnd!=pWndPopup)
			pWndPopup->SetForegroundWindow();
	}
}
void CPointtestView::OnHGrip()
{
	if(m_pBaseTool){
		m_pList->HGripSelected();
		m_pBaseTool->Draw();
	}
}
void CPointtestView::OnVGrip()
{
	if(m_pBaseTool){
		m_pList->VGripSelected();
		m_pBaseTool->Draw();
	}
}
void CPointtestView::OnAntiClockWise()
{
	if(m_pBaseTool){
		m_pList->RotateSelected(45);
		m_pBaseTool->Draw();
	}
}
void CPointtestView::OnSeaZil()
{
	if(m_pBaseTool){
		m_pList->RotateSelected(-45);
		m_pBaseTool->Draw();

⌨️ 快捷键说明

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