|
|
|
|
#include "StdAfx.h"
|
|
|
|
|
#include "Ruler.h"
|
|
|
|
|
#include "GlobalDrawMgr.h"
|
|
|
|
|
#include "GlobalFunction.h"
|
|
|
|
|
#include "Propertie.h"
|
|
|
|
|
#include "PropertieMgr.h"
|
|
|
|
|
#include "WorkAreaMgr.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define RULER_WIDETH (22) //<2F><><EFBFBD>ߵĿ<DFB5><C4BF><EFBFBD>--(<28><>λ:<3A><><EFBFBD><EFBFBD>)<29><>view<65><77><EFBFBD><EFBFBD><EFBFBD>仯
|
|
|
|
|
#define RULER_GAP (1) //<2F><><EFBFBD>ߵļ<DFB5><C4BC><EFBFBD>--(<28><>λ:<3A><><EFBFBD><EFBFBD>)
|
|
|
|
|
#define RULER_NUM_WIDTH (6) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵĿ<D6B5><C4BF><EFBFBD>--(<28><>λ:<3A><><EFBFBD><EFBFBD>)<29><>view<65><77><EFBFBD><EFBFBD><EFBFBD>仯
|
|
|
|
|
#define RULER_NUM_HEIGHT (10) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵĸ߶<C4B8>--(<28><>λ:<3A><><EFBFBD><EFBFBD>)<29><>view<65><77><EFBFBD><EFBFBD><EFBFBD>仯
|
|
|
|
|
|
|
|
|
|
CRuler *gRuler = new CRuler;
|
|
|
|
|
CRuler::CRuler(void)
|
|
|
|
|
{
|
|
|
|
|
m_bDrawRuler = true;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD>
|
|
|
|
|
m_MousePointTmp.x = -1;//<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱλ<CAB1><CEBB>
|
|
|
|
|
m_MousePointTmp.y = -1;
|
|
|
|
|
}
|
|
|
|
|
CRuler::~CRuler(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
CMFCPropertyGridProperty *CRuler::CreatGridProperty()
|
|
|
|
|
{
|
|
|
|
|
CString PropertyName;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CString Description;//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
CString Path = _T("LogMgr");;//<2F>洢·<E6B4A2><C2B7>
|
|
|
|
|
CString Name;
|
|
|
|
|
//-------------------------------------------------------------------------------//
|
|
|
|
|
PropertyName = _T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
|
|
|
|
|
//-------------------------------------------------------------------------------//
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
|
|
|
|
|
Name = _T("m_bDrawRuler");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
|
|
pPropertie->SetpVal((void*)&m_bDrawRuler);
|
|
|
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
|
|
|
pPropertie->SetpModule(this);
|
|
|
|
|
pPropertie->SetPath(Path);
|
|
|
|
|
pPropertie->SetName(Name);
|
|
|
|
|
pPropertie->WriteRead(true);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
PropertyName = _T("<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
Description = _T("<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><>С<EFBFBD><D0A1>λ: mm)");
|
|
|
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bDrawRuler, Description);
|
|
|
|
|
pGroup->AddSubItem(p1);
|
|
|
|
|
|
|
|
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
|
|
|
}
|
|
|
|
|
//-------------------------------------------------------------------------------//
|
|
|
|
|
return pGroup;
|
|
|
|
|
}
|
|
|
|
|
void CRuler::OnPropertyChanged()
|
|
|
|
|
{
|
|
|
|
|
//<2F><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
|
|
|
|
CLaiPuLaserView *pView = GetCurViewPtr();
|
|
|
|
|
if(pView)
|
|
|
|
|
{
|
|
|
|
|
pView->RefreshView();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void CRuler::Draw(CDC* pDC)
|
|
|
|
|
{
|
|
|
|
|
DrawRuler(pDC);
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD>
|
|
|
|
|
void CRuler::DrawRuler(CDC* pDC)
|
|
|
|
|
{
|
|
|
|
|
if(!m_bDrawRuler)
|
|
|
|
|
return;
|
|
|
|
|
//<2F><>ȡ<EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>Χ
|
|
|
|
|
CRect rect;
|
|
|
|
|
GetCurViewPtr()->GetClientRect(&rect);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>ڿͻ<DABF><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
pDC->DPtoLP(rect);//ת<><D7AA>Ϊ<EFBFBD><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
int RulerWideth = GetCurViewPtr()->GetCurrScaleVal(RULER_WIDETH);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ߵij<DFB5><C4B3><EFBFBD>
|
|
|
|
|
int ShortLen = RulerWideth/4;
|
|
|
|
|
int ShortLen2 = RulerWideth/6;
|
|
|
|
|
int MidLen = RulerWideth/2;
|
|
|
|
|
int LongLen;
|
|
|
|
|
double zoomScale = GetCurViewPtr()->GetCurZoomScale();
|
|
|
|
|
if(zoomScale>VIEW_SCALE9)
|
|
|
|
|
{
|
|
|
|
|
LongLen = RulerWideth/2;
|
|
|
|
|
}
|
|
|
|
|
else//<2F><><EFBFBD><EFBFBD>̫С<CCAB><D0A1>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
LongLen = RulerWideth/3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CPen pen;
|
|
|
|
|
pen.CreatePen(PS_SOLID,0.5,RGB_BLACK);
|
|
|
|
|
CBrush brush ;
|
|
|
|
|
brush.CreateSolidBrush(RGB_GRAY) ;
|
|
|
|
|
CPen* pOldPen = (CPen*)pDC->SelectObject(&pen);
|
|
|
|
|
CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&brush);
|
|
|
|
|
|
|
|
|
|
int RulerX,RulerY;
|
|
|
|
|
RulerX = rect.left+RulerWideth;
|
|
|
|
|
RulerY = rect.top+RulerWideth;
|
|
|
|
|
//ˮƽ<CBAE><C6BD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>)
|
|
|
|
|
CRect DrawRectH(0,rect.top,SCROLL_SIZE_CX,RulerY);
|
|
|
|
|
pDC->Rectangle(DrawRectH);
|
|
|
|
|
//<2F><>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>)
|
|
|
|
|
CRect DrawRectV(rect.left,0,RulerX,SCROLL_SIZE_CY);
|
|
|
|
|
pDC->Rectangle(DrawRectV);
|
|
|
|
|
|
|
|
|
|
int count;//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
int StartX = LOGIC_CENTER_X;
|
|
|
|
|
int StartY = LOGIC_CENTER_Y;
|
|
|
|
|
int gap;//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
gap = gDraw->Double2Int(1);//ÿ10 <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
pDC->SetBkMode(TRANSPARENT);//<2F><><EFBFBD><EFBFBD><EFBFBD><CDB8>
|
|
|
|
|
CString FontTypeStr("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
double TextHeight = GetCurViewPtr()->GetCurrScaleVal(RULER_NUM_HEIGHT);//<2F>߶<EFBFBD>
|
|
|
|
|
double TextWidth = GetCurViewPtr()->GetCurrScaleVal(RULER_NUM_WIDTH);//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ˮƽ<CBAE><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--------------------------------------------------------
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>------------------------------------------------------
|
|
|
|
|
SetCurFont(pDC,TextHeight,TextWidth,0,FALSE,FontTypeStr);
|
|
|
|
|
|
|
|
|
|
DbSize size = gWorkAreaMgr->GetWorkArea().GetSize();
|
|
|
|
|
int WorkSpaceWeidth = size.w;
|
|
|
|
|
int WorkSpaceHeight = size.h;
|
|
|
|
|
|
|
|
|
|
double Scale1 = VIEW_SCALE1;
|
|
|
|
|
double Scale2 = VIEW_SCALE1;
|
|
|
|
|
double Scale3 = VIEW_SCALE1;
|
|
|
|
|
#if 1//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
count = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
for(int i=0;i<=(WorkSpaceWeidth);i += gap)
|
|
|
|
|
{
|
|
|
|
|
//<2F>ڹ<EFBFBD><DAB9><EFBFBD><EFBFBD>ռ䷶Χ<E4B7B6><CEA7><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
if(zoomScale>Scale1)//ȫ<><C8AB><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
{
|
|
|
|
|
DrawRulerNum(pDC,count*10,StartX+i,RulerY-RulerWideth,TextWidth,TRUE);
|
|
|
|
|
}
|
|
|
|
|
else if(zoomScale>Scale2)//ÿ20 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
{
|
|
|
|
|
if(count%2 == 0)
|
|
|
|
|
{
|
|
|
|
|
DrawRulerNum(pDC,count*10,StartX+i,RulerY-RulerWideth,TextWidth,TRUE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(zoomScale>Scale3)//ÿ50 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
{
|
|
|
|
|
if(count%5 == 0)
|
|
|
|
|
{
|
|
|
|
|
DrawRulerNum(pDC,count*10,StartX+i,RulerY-RulerWideth,TextWidth,TRUE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else//ÿ200 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
{
|
|
|
|
|
if(count%20 == 0)
|
|
|
|
|
{
|
|
|
|
|
DrawRulerNum(pDC,count*10,StartX+i,RulerY-RulerWideth,TextWidth,TRUE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if 1//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
count = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
for(int i=0;i<=(WorkSpaceWeidth);i += gap)
|
|
|
|
|
{
|
|
|
|
|
if(count !=0)
|
|
|
|
|
{
|
|
|
|
|
//<2F>ڹ<EFBFBD><DAB9><EFBFBD><EFBFBD>ռ䷶Χ<E4B7B6><CEA7><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
if(zoomScale>Scale1)//ȫ<><C8AB><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
{
|
|
|
|
|
DrawRulerNum(pDC,count*10,StartX-i,RulerY-RulerWideth,TextWidth,TRUE);
|
|
|
|
|
}
|
|
|
|
|
else if(zoomScale>Scale2)//ÿ20 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
{
|
|
|
|
|
if(count%2 == 0)
|
|
|
|
|
{
|
|
|
|
|
DrawRulerNum(pDC,count*10,StartX-i,RulerY-RulerWideth,TextWidth,TRUE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(zoomScale>Scale3)//ÿ50 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
{
|
|
|
|
|
if(count%5 == 0)
|
|
|
|
|
{
|
|
|
|
|
DrawRulerNum(pDC,count*10,StartX-i,RulerY-RulerWideth,TextWidth,TRUE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else//ÿ200 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
{
|
|
|
|
|
if(count%20 == 0)
|
|
|
|
|
{
|
|
|
|
|
DrawRulerNum(pDC,count*10,StartX-i,RulerY-RulerWideth,TextWidth,TRUE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD>ƴ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--------------------------------------------------------
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>------------------------------------------------------
|
|
|
|
|
SetCurFont(pDC,TextHeight,TextWidth,90,FALSE,FontTypeStr);
|
|
|
|
|
count = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
for(int i=0;i<=(WorkSpaceWeidth);i += gap)
|
|
|
|
|
{
|
|
|
|
|
//<2F>ڹ<EFBFBD><DAB9><EFBFBD><EFBFBD>ռ䷶Χ<E4B7B6><CEA7><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
if(zoomScale>Scale1)//ȫ<><C8AB><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
{
|
|
|
|
|
DrawRulerNum(pDC,count*10,RulerX-RulerWideth,StartY-i,TextWidth,FALSE);
|
|
|
|
|
}
|
|
|
|
|
else if(zoomScale>Scale2)//ÿ20 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
{
|
|
|
|
|
if(count%2 == 0)
|
|
|
|
|
{
|
|
|
|
|
DrawRulerNum(pDC,count*10,RulerX-RulerWideth,StartY-i,TextWidth,FALSE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(zoomScale>Scale3)//ÿ50 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
{
|
|
|
|
|
if(count%5 == 0)
|
|
|
|
|
{
|
|
|
|
|
DrawRulerNum(pDC,count*10,RulerX-RulerWideth,StartY-i,TextWidth,FALSE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else//ÿ200 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
{
|
|
|
|
|
if(count%20 == 0)
|
|
|
|
|
{
|
|
|
|
|
DrawRulerNum(pDC,count*10,RulerX-RulerWideth,StartY-i,TextWidth,FALSE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
count = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
for(int i=0;i<=(WorkSpaceWeidth);i += gap)
|
|
|
|
|
{
|
|
|
|
|
if(count != 0)
|
|
|
|
|
{
|
|
|
|
|
//<2F>ڹ<EFBFBD><DAB9><EFBFBD><EFBFBD>ռ䷶Χ<E4B7B6><CEA7><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
if(zoomScale>Scale1)//ȫ<><C8AB><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
{
|
|
|
|
|
DrawRulerNum(pDC,count*10,RulerX-RulerWideth,StartY+i,TextWidth,FALSE);
|
|
|
|
|
}
|
|
|
|
|
else if(zoomScale>Scale2)//ÿ20 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
{
|
|
|
|
|
if(count%2 == 0)
|
|
|
|
|
{
|
|
|
|
|
DrawRulerNum(pDC,count*10,RulerX-RulerWideth,StartY+i,TextWidth,FALSE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(zoomScale>Scale3)//ÿ50 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
{
|
|
|
|
|
if(count%5 == 0)
|
|
|
|
|
{
|
|
|
|
|
DrawRulerNum(pDC,count*10,RulerX-RulerWideth,StartY+i,TextWidth,FALSE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else//ÿ200 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
{
|
|
|
|
|
if(count%20 == 0)
|
|
|
|
|
{
|
|
|
|
|
DrawRulerNum(pDC,count*10,RulerX-RulerWideth,StartY+i,TextWidth,FALSE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
//ˮƽ<CBAE><C6BD><EFBFBD>ߵĺ<DFB5><C4BA><EFBFBD>
|
|
|
|
|
pDC->MoveTo(0,RulerY);
|
|
|
|
|
pDC->LineTo(SCROLL_SIZE_CX,RulerY);
|
|
|
|
|
//<2F><>ֱ<EFBFBD><D6B1><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
pDC->MoveTo(RulerX,0);
|
|
|
|
|
pDC->LineTo(RulerX,SCROLL_SIZE_CY);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>----------------------------------------------------------
|
|
|
|
|
count = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
gap = gDraw->Double2Int(RULER_GAP);
|
|
|
|
|
for(int i=0;i<(SCROLL_SIZE_CX/2);i += gap)
|
|
|
|
|
{
|
|
|
|
|
if(count%10 == 0)//ÿ10 <20><><EFBFBD><EFBFBD><D7BB><EFBFBD><EEB3A4>
|
|
|
|
|
{
|
|
|
|
|
if(zoomScale>VIEW_SCALE3)//С<><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
{
|
|
|
|
|
//ˮƽ<CBAE><C6BD><EFBFBD><EFBFBD>
|
|
|
|
|
pDC->MoveTo(StartX+i,RulerY);
|
|
|
|
|
pDC->LineTo(StartX+i,RulerY-LongLen);
|
|
|
|
|
pDC->MoveTo(StartX-i,RulerY);
|
|
|
|
|
pDC->LineTo(StartX-i,RulerY-LongLen);
|
|
|
|
|
//<2F><>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>
|
|
|
|
|
pDC->MoveTo(RulerX,StartY+i);
|
|
|
|
|
pDC->LineTo(RulerX-LongLen,StartY+i);
|
|
|
|
|
pDC->MoveTo(RulerX,StartY-i);
|
|
|
|
|
pDC->LineTo(RulerX-LongLen,StartY-i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(count%5 == 0)//ÿ5 <20><><EFBFBD><EFBFBD><D7BB>еȵ<D0B5>
|
|
|
|
|
{
|
|
|
|
|
if(zoomScale>VIEW_SCALE7)//С<><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
{
|
|
|
|
|
//ˮƽ<CBAE><C6BD><EFBFBD><EFBFBD>
|
|
|
|
|
pDC->MoveTo(StartX+i,RulerY);
|
|
|
|
|
pDC->LineTo(StartX+i,RulerY-MidLen);
|
|
|
|
|
pDC->MoveTo(StartX-i,RulerY);
|
|
|
|
|
pDC->LineTo(StartX-i,RulerY-MidLen);
|
|
|
|
|
//<2F><>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>
|
|
|
|
|
pDC->MoveTo(RulerX,StartY+i);
|
|
|
|
|
pDC->LineTo(RulerX-MidLen,StartY+i);
|
|
|
|
|
pDC->MoveTo(RulerX,StartY-i);
|
|
|
|
|
pDC->LineTo(RulerX-MidLen,StartY-i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else//ÿ1 <20><><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if(zoomScale>VIEW_SCALE12)//С<><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
{
|
|
|
|
|
//ˮƽ<CBAE><C6BD><EFBFBD><EFBFBD>
|
|
|
|
|
pDC->MoveTo(StartX+i,RulerY);
|
|
|
|
|
pDC->LineTo(StartX+i,RulerY-ShortLen);
|
|
|
|
|
pDC->MoveTo(StartX-i,RulerY);
|
|
|
|
|
pDC->LineTo(StartX-i,RulerY-ShortLen);
|
|
|
|
|
//<2F><>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>
|
|
|
|
|
pDC->MoveTo(RulerX,StartY+i);
|
|
|
|
|
pDC->LineTo(RulerX-ShortLen,StartY+i);
|
|
|
|
|
pDC->MoveTo(RulerX,StartY-i);
|
|
|
|
|
pDC->LineTo(RulerX-ShortLen,StartY-i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
if(zoomScale>VIEW_SCALE20)//<2F>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ0.1 <20><><EFBFBD><EFBFBD><D7BC><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
gap /= 10;//<2F><><EFBFBD><EFBFBD>Ϊ0.1 <20><><EFBFBD><EFBFBD>
|
|
|
|
|
//ֻ<>ڹ<EFBFBD><DAB9><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC>ķ<EFBFBD>Χ<EFBFBD><CEA7>ʾ
|
|
|
|
|
int max = max((int)WorkSpaceHeight,(int)WorkSpaceWeidth);
|
|
|
|
|
for(int i=0;i<(max);i += gap)
|
|
|
|
|
{
|
|
|
|
|
//ˮƽ<CBAE><C6BD><EFBFBD><EFBFBD>
|
|
|
|
|
pDC->MoveTo(StartX+i,RulerY);
|
|
|
|
|
pDC->LineTo(StartX+i,RulerY-ShortLen2);
|
|
|
|
|
pDC->MoveTo(StartX-i,RulerY);
|
|
|
|
|
pDC->LineTo(StartX-i,RulerY-ShortLen2);
|
|
|
|
|
//<2F><>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>
|
|
|
|
|
pDC->MoveTo(RulerX,StartY+i);
|
|
|
|
|
pDC->LineTo(RulerX-ShortLen2,StartY+i);
|
|
|
|
|
pDC->MoveTo(RulerX,StartY-i);
|
|
|
|
|
pDC->LineTo(RulerX-ShortLen2,StartY-i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>
|
|
|
|
|
CRect DrawRect(rect.left,rect.top,rect.left+RulerWideth,rect.top+RulerWideth);
|
|
|
|
|
pDC->Rectangle(DrawRect);
|
|
|
|
|
|
|
|
|
|
pDC->SelectObject(pOldBrush);
|
|
|
|
|
pDC->SelectObject(pOldPen);
|
|
|
|
|
|
|
|
|
|
m_MousePointTmp.x = -1;
|
|
|
|
|
m_MousePointTmp.y = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD>Ʊ<EFBFBD><C6B1>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD>,bIsX == TRUEΪX <20><><EFBFBD><EFBFBD>
|
|
|
|
|
void CRuler::DrawRulerNum(CDC* pDC,int Num,int CurX,int CurY,double TextWidth,BOOL bIsX)
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>Num <20>м<EFBFBD>λ
|
|
|
|
|
int NumTmp = Num;
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
while(NumTmp>0)
|
|
|
|
|
{
|
|
|
|
|
NumTmp /=10;
|
|
|
|
|
cnt++;
|
|
|
|
|
}
|
|
|
|
|
if(cnt==0)//ֻ<><D6BB>һλʱ
|
|
|
|
|
{
|
|
|
|
|
cnt = 1;
|
|
|
|
|
}
|
|
|
|
|
if(bIsX)
|
|
|
|
|
{
|
|
|
|
|
CurX -= (cnt*TextWidth)/2;//ˮƽ<CBAE><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB>һ<EFBFBD><D2BB>
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CurY += (cnt*TextWidth)/2;//<2F><>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>±<EFBFBD>ƫ<EFBFBD><C6AB>һ<EFBFBD><D2BB>
|
|
|
|
|
}
|
|
|
|
|
CString TextString;
|
|
|
|
|
TextString.Format("%d",Num);
|
|
|
|
|
const char* pStr=(const char*)TextString;
|
|
|
|
|
int StrLen = strlen(pStr);
|
|
|
|
|
while(StrLen>0)
|
|
|
|
|
{
|
|
|
|
|
unsigned char char1;
|
|
|
|
|
char Char[3];
|
|
|
|
|
char1 = *pStr;
|
|
|
|
|
strncpy(Char,pStr,1);
|
|
|
|
|
Char[1]='\0';
|
|
|
|
|
pStr += 1;
|
|
|
|
|
StrLen -= 1;
|
|
|
|
|
pDC->TextOut(CurX,CurY,Char);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
|
|
|
|
if(bIsX)
|
|
|
|
|
{
|
|
|
|
|
CurX += TextWidth;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CurY -= TextWidth;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
|
|
|
|
CFont* CRuler::SetCurFont(CDC *pDC,double TextHeight,double TextWidth,double RotateAngle,bool bIsItalic,CString FontTypeStr)
|
|
|
|
|
{
|
|
|
|
|
//ʹ<>õ<EFBFBD>ǰͼ<C7B0>ε<EFBFBD><CEB5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CFont font,*pOldFont;
|
|
|
|
|
font.CreateFont (
|
|
|
|
|
TextHeight, //<2F><>
|
|
|
|
|
0,//TextWidth, //<2F><>
|
|
|
|
|
RotateAngle*10, //<2F>Ƕ<EFBFBD>
|
|
|
|
|
0,
|
|
|
|
|
FW_NORMAL,
|
|
|
|
|
bIsItalic, //б<><D0B1>
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
DEFAULT_CHARSET, //<2F>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
OUT_CHARACTER_PRECIS,
|
|
|
|
|
CLIP_CHARACTER_PRECIS,
|
|
|
|
|
DEFAULT_QUALITY,
|
|
|
|
|
DEFAULT_PITCH |FF_DONTCARE,
|
|
|
|
|
FontTypeStr);//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
pOldFont = pDC->SelectObject(&font);
|
|
|
|
|
return pOldFont;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
void CRuler::DrawMousePos(CDC* pDC,CPoint point)
|
|
|
|
|
{
|
|
|
|
|
if(!m_bDrawRuler)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
double zoomScale = GetCurViewPtr()->GetCurZoomScale();
|
|
|
|
|
int RulerWideth = RULER_WIDETH/zoomScale;
|
|
|
|
|
int CheckGap = RulerWideth/2;//<2F><><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD>
|
|
|
|
|
//<2F><>ȡ<EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>Χ
|
|
|
|
|
CRect rect;
|
|
|
|
|
GetCurViewPtr()->GetClientRect(&rect);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>ڿͻ<DABF><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
pDC->DPtoLP(rect);//ת<><D7AA>Ϊ<EFBFBD><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>µ<EFBFBD>,<2C>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if(m_MousePointTmp.x == -1)
|
|
|
|
|
{
|
|
|
|
|
DrawRuler(pDC);
|
|
|
|
|
}
|
|
|
|
|
int old_rop = pDC->SetROP2(R2_XORPEN);
|
|
|
|
|
CPen pen;
|
|
|
|
|
pen.CreatePen(PS_SOLID,0.5,RGB_GRAY);
|
|
|
|
|
CPen* pOldPen = (CPen*)pDC->SelectObject(&pen);
|
|
|
|
|
|
|
|
|
|
int RulerX,RulerY;
|
|
|
|
|
RulerX = rect.left+RulerWideth;
|
|
|
|
|
RulerY = rect.top+RulerWideth;
|
|
|
|
|
RulerX -= 1;//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
RulerY -= 1;//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
//ˮƽ
|
|
|
|
|
pDC->MoveTo(m_MousePointTmp.x,RulerY);
|
|
|
|
|
pDC->LineTo(m_MousePointTmp.x,RulerY-RulerWideth);
|
|
|
|
|
pDC->MoveTo(RulerX,m_MousePointTmp.y);
|
|
|
|
|
pDC->LineTo(RulerX-RulerWideth,m_MousePointTmp.y);
|
|
|
|
|
//<2F><>ֱ
|
|
|
|
|
pDC->MoveTo(point.x,RulerY);
|
|
|
|
|
pDC->LineTo(point.x,RulerY-RulerWideth);
|
|
|
|
|
pDC->MoveTo(RulerX,point.y);
|
|
|
|
|
pDC->LineTo(RulerX-RulerWideth,point.y);
|
|
|
|
|
|
|
|
|
|
pDC->SelectObject(pOldPen);
|
|
|
|
|
pDC->SetROP2(old_rop);
|
|
|
|
|
}
|