Old fashion design for PC-104
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright � 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 08/10/2003
// PROJECT:
// SUBSYSTEM:
// FILE: auxlib.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of AUXLIB.CPP
//----------------------------------------------------------------------------
#include "StdAfx.h"
#include "AuxLib.h"
#include "..\..\LgLib\Version.h"
double CalcViewRectAndScale( CRect& mapRect, CRect *pViewRect ){ double k = ((double)mapRect.Height()) / ((double)mapRect.Width()); CRect rect; rect = *pViewRect; rect.right = (int)(((double)rect.left) + ((double)rect.Height()) / k ); if( rect.Width() > pViewRect->Width() ) { rect = *pViewRect; rect.bottom = (int)(((double)rect.top) + ((double)rect.Width()) * k ); } *pViewRect = rect; return ((double)rect.Width()) / ((double)mapRect.Width());}
CRect CalcDrawRect( CRect& viewRect, CSize& mapSize, SDPOINT& mapShift, double scale ){ double cx = mapSize.cx * scale; double cy = mapSize.cy * scale; double x = mapShift.x * cx; double y = mapShift.y * cy; CRect rect; rect.left = (int)(viewRect.left - x); rect.top = (int)(viewRect.top - y); rect.right = (int)(rect.left + cx); rect.bottom = (int)(rect.top + cy); return rect;}/*
CRect CalcDrawRectCentral( CRect& viewRect, CSize& mapSize, DPOINT& mapShift, double scale ){ double cx = mapSize.cx * scale; double cy = mapSize.cy * scale; double x = mapShift.x * cx; double y = mapShift.y * cy; CRect rect; rect.left = (int)( 0.5 * (viewRect.left + viewRect.right) - x ); rect.top = (int)( 0.5 * ( viewRect.top + viewRect.bottom) - y ); rect.right = (int)(rect.left + cx); rect.bottom = (int)(rect.top + cy); return rect;}*/CPoint CalcDrawPoint( CRect& viewRect, CSize& mapSize, SDPOINT& mapPoint, double scale ){ double x = mapPoint.x * mapSize.cx * scale; double y = mapPoint.y * mapSize.cy * scale; return CPoint( (int)(viewRect.left + x), (int)(viewRect.top + y) );}
SDPOINT CalcMapPoint( CPoint& viewPoint, CSize& mapSize, SDPOINT& mapShift, double scale ){ SDPOINT point;
point.x = ((double)(viewPoint.x + mapShift.x * mapSize.cx * scale)) / ((double)mapSize.cx * scale); point.y = ((double)(viewPoint.y + mapShift.y * mapSize.cy * scale)) / ((double)mapSize.cy * scale);
return point;}
SDPOINT CalcViewCenterShift( CRect& viewRect, CSize& mapSize, double scale ){ double cx = mapSize.cx * scale; double cy = mapSize.cy * scale;
double dx = 0.5 * (double)viewRect.Width(); double dy = 0.5 * (double)viewRect.Height();
return SDPOINT( dx / cx, dy / cy );}
BOOL FindTag( FILE_TAG *pTag, int nTagCount, LPCTSTR pTagName, LPDWORD pFilePtr ){ for( int i = 0; i < nTagCount; i++ ) { if( !_strnicmp( pTag[i].pName, pTagName, strlen( pTagName ) ) ) { *pFilePtr = pTag[i].iStart; return TRUE; } } return FALSE;}
|