📄 zoomtool.cpp
字号:
/*
This file is part of SWAIN (http://sourceforge.net/projects/swain).
Copyright (C) 2006 Daniel Lindstr鰉 and Daniel Nilsson
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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "StdAfx.h"
#include "ZoomTool.h"
#include "PacketBounds.h"
// How much to zoom when the pointer is moved across the screen in each direction
const float ZOOM_FACTOR_X = 4.0f;
const float ZOOM_FACTOR_Y = -4.0f;
ZoomTool::ZoomTool(ViewPort *vp, ConnectionHandler *ch, int cid) {
this->viewport = vp;
this->connhand = ch;
this->cid = cid;
this->followme = false;
}
ZoomTool::~ZoomTool(void) {
}
void ZoomTool::mouseDown(FPOINT *point) {
transformPoint(point, &downpoint);
viewport->getPan(&origin);
startzoom = viewport->getZoom();
FRECT rect;
viewport->getBounds(&rect);
PacketBounds *pb = new PacketBounds(rect, followme);
pb->setCId(cid);
connhand->sendPacket(pb);
}
void ZoomTool::mouseUp(FPOINT *point) {
}
void ZoomTool::mouseDragged(FPOINT *point) {
FPOINT pt;
transformPoint(point, &pt);
float zoom = startzoom +
ZOOM_FACTOR_X * (pt.x - downpoint.x) +
ZOOM_FACTOR_Y * (pt.y - downpoint.y);
zoom = min(zoom, viewport->getMaxZoom());
zoom = max(zoom, viewport->getMinZoom());
FPOINT pan = {
origin.x + (downpoint.x/startzoom - downpoint.x/zoom),
origin.y + (downpoint.y/startzoom - downpoint.y/zoom)
};
viewport->setZoomPan(zoom, &pan);
FRECT rect;
viewport->getBounds(&rect);
PacketBounds *pb = new PacketBounds(rect, followme);
pb->setCId(cid);
connhand->sendPacket(pb);
}
void ZoomTool::setFollowMe(bool followme){
this->followme = followme;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -