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

📄 coordtrans.cpp

📁 虚拟打印机
💻 CPP
字号:
/* * * coordtrans.cpp *   Copyright (C) 2006 Michael H. Overlin   This program is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; either version 2 of the License, or   (at your option) any later version.   This program is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with this program; if not, write to the Free Software   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA      Contact at poster_printer@yahoo.com */#include "coordtrans.h"#include "mathutils.h"#include <windows.h>CoordTrans::CoordTrans(void) {	this->dZoom = 1.0;	this->dScale = 1.0;	this->ptdDestOrg.x = 0;	this->ptdDestOrg.y = 0;	this->ptdSrcOrg.x = 0;	this->ptdSrcOrg.y = 0;}void CoordTrans::Reset(IN const POINTD& ptdSrc, IN const POINT& ptDest, IN double _dZoom,								   IN const RECTD&rdSrcNominal, IN const RECT& rDestNominal) {	double dZoom1 = RW(rDestNominal) / RW(rdSrcNominal);	double dZoom2 = RH(rDestNominal) / RH(rdSrcNominal);	double dZoom3 = min(dZoom1, dZoom2);	this->dZoom = _dZoom;	this->dScale = this->dZoom * dZoom3;	this->ptdDestOrg.x = ptDest.x;	this->ptdDestOrg.y = ptDest.y;	this->ptdSrcOrg = ptdSrc;}void CoordTrans::DoTrans(IN const POINTD& ptdSrc, OUT POINT& ptDest) const {	ptDest.x = RoundToLong( (ptdSrc.x - this->ptdSrcOrg.x) * this->dScale + this->ptdDestOrg.x );	ptDest.y = RoundToLong( (ptdSrc.y - this->ptdSrcOrg.y) * this->dScale + this->ptdDestOrg.y );}void CoordTrans::DoTrans(IN const RECTD& rdSrc, OUT RECT& rDest) const {	rDest.left = RoundToLong( (rdSrc.left - this->ptdSrcOrg.x) * this->dScale + this->ptdDestOrg.x );	rDest.top = RoundToLong( (rdSrc.top - this->ptdSrcOrg.y) * this->dScale + this->ptdDestOrg.y );	rDest.right = RoundToLong( (rdSrc.right - this->ptdSrcOrg.x) * this->dScale + this->ptdDestOrg.x );	rDest.bottom = RoundToLong( (rdSrc.bottom - this->ptdSrcOrg.y) * this->dScale + this->ptdDestOrg.y );}void CoordTrans::DoInvTrans(IN const POINT& ptDest, OUT POINTD& ptdSrc) const {	ptdSrc.x = (ptDest.x - this->ptdDestOrg.x) / this->dScale + this->ptdSrcOrg.x;	ptdSrc.y = (ptDest.y - this->ptdDestOrg.y) / this->dScale + this->ptdSrcOrg.y;}void CoordTrans::DoInvTrans(IN const RECT& rDest, OUT RECTD& rdSrc) const {	rdSrc.left = (rDest.left - this->ptdDestOrg.x) / this->dScale + this->ptdSrcOrg.x;	rdSrc.top = (rDest.top - this->ptdDestOrg.y) / this->dScale + this->ptdSrcOrg.y;	rdSrc.right = (rDest.right - this->ptdDestOrg.x) / this->dScale + this->ptdSrcOrg.x;	rdSrc.bottom = (rDest.bottom - this->ptdDestOrg.y) / this->dScale + this->ptdSrcOrg.y;}void CoordTrans::TranslateSrcOrg(IN const POINT& ptDestOffset) {	this->ptdSrcOrg.x -= ptDestOffset.x / this->dScale;	this->ptdSrcOrg.y -= ptDestOffset.y / this->dScale;}void CoordTrans::SetZoom(double _dZoom) {	this->dScale *= _dZoom / this->dZoom;	this->dZoom = _dZoom;}//7/8void CoordTrans::SetNewOrgs(IN const POINTD& ptdNewSrcOrg, IN const POINT& ptNewDestOrg) {	this->ptdSrcOrg = ptdNewSrcOrg;	this->ptdDestOrg.x = ptNewDestOrg.x;	this->ptdDestOrg.y = ptNewDestOrg.y;}

⌨️ 快捷键说明

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