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

📄 hrulerwnd.cpp

📁 又VC++实现的基于TWAIN的扫描仪图像输入处理软件
💻 CPP
字号:
//水平标尺显示

#include "stdafx.h"
#include "source10.h"
#include "HRulerWnd.h"
#include "Data.h"
#include "const.h"
#include "ViewWnd.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
//构造函数和析构函数                                                       //
/////////////////////////////////////////////////////////////////////////////
CHRulerWnd::CHRulerWnd()
{
}
CHRulerWnd::~CHRulerWnd()
{
}

/////////////////////////////////////////////////////////////////////////////
//消息映射                                                           //
/////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CHRulerWnd, CWnd)
  //{{AFX_MSG_MAP(CHRulerWnd)
	  ON_WM_PAINT()
  //}}AFX_MSG_MAP
END_MESSAGE_MAP()

extern CViewWnd *pViewWnd;
extern CData *pData;

/////////////////////////////////////////////////////////////////////////////
//当水平标尺窗口出现时画标尺,标尺也随着缩放比例的变化而变化
/////////////////////////////////////////////////////////////////////////////
void CHRulerWnd::OnPaint() 
{
	CPaintDC dc(this); 
	CPen pen(PS_SOLID, 0, RGB(0,0,0));   
	
	dc.SetMapMode(MM_ANISOTROPIC);
	//设备空间坐标和逻辑空间坐标模式转换为水平ZOOMFACTER/1和1/1
	dc.SetWindowExt(pData->m_nZoomFactor, 1);
	dc.SetViewportExt(1,1);
    dc.SetWindowOrg(0, 0);
    dc.SetWindowOrg(pData->m_ptPaintOrg.x, 0);
	
	int LogLenX = (int)(pData->m_szLogImageSize.cx*FuMian/pData->m_szScanFrame.cx) ;	
	int nIndicatorLen = 0;

	
    if(pData->m_nZoomFactor==4||pData->m_nZoomFactor==8)
	{
	   if(pData->m_nZoomFactor==8)
	   {
	     for (int i=0,j=0,nIndPos=0; i<pData->m_szLogImageSize.cx/5/LogLenX; i++)
		 {
	 	    nIndicatorLen = ((i+1)%2==0)? IL_LONG:IL_MEDIUM2;
		    nIndPos += LogLenX * 5;
		    dc.MoveTo(nIndPos, nIndicatorLen);
		    dc.LineTo(nIndPos, HRULER_BOTTOM);
      	 }
	   }
 	  if(pData->m_nZoomFactor==4)
	  {
	     for (int i=0,j=0,nIndPos=0; i<pData->m_szLogImageSize.cx/LogLenX; i++)
		 {
		    nIndicatorLen = ((i+1)%5==0)? IL_LONG:IL_MEDIUM1;
		    nIndPos += LogLenX;
		    dc.MoveTo(nIndPos, nIndicatorLen);
		    dc.LineTo(nIndPos, HRULER_BOTTOM);
      	 }
	  }

	  
      //A0  1000个点为1英寸
      dc.TextOut(502,1,"5",1);
	  dc.TextOut(1002,1,"10",2);
      dc.TextOut(1502,1,"15",2);
	  dc.TextOut(2002,1,"20",2);
	  dc.TextOut(2502,1,"25",2);
      dc.TextOut(3002,1,"30",2);
      dc.TextOut(3502,1,"35",2);


	  /*//A1  1300个点为1英寸
      dc.TextOut(652,1,"5",1);
	  dc.TextOut(1302,1,"10",2);
      dc.TextOut(1952,1,"15",2);
	  dc.TextOut(2602,1,"20",2);
	  dc.TextOut(3252,1,"25",2);*/

	  //西飞 600个点为1英寸
	  /*dc.TextOut(602,1,"10",2);
	  dc.TextOut(1202,1,"20",2);
      dc.TextOut(1802,1,"30",2);
      dc.TextOut(2402,1,"40",2); 
      dc.TextOut(3002,1,"50",2);
      dc.TextOut(3602,1,"60",2);
      dc.TextOut(4002,1,"70",2);*/
	}

   if(pData->m_nZoomFactor==2||pData->m_nZoomFactor==1)
   {
       if(pData->m_nZoomFactor==2)
	   {
	     for (int i=0,j=0,nIndPos=0; i<pData->m_szLogImageSize.cx/(LogLenX/5); i++)
		 {
		   if((i+1)%25==0)
		   {
			nIndicatorLen=IL_LONG;
		   }
		  else if((i+1)%5==0)
		  {
			nIndicatorLen =IL_MEDIUM1;
		  }
		  else
		  {
		    nIndicatorLen =IL_SHORT;	
		  }
		  nIndPos += LogLenX/5;
		 dc.MoveTo(nIndPos, nIndicatorLen);
		 dc.LineTo(nIndPos, HRULER_BOTTOM);
		 }
	   }
	  if(pData->m_nZoomFactor==1)
	  {
	    for (int i=0,j=0,nIndPos=0; i<pData->m_szLogImageSize.cx/(LogLenX/10); i++)
		{
		   if((i+1)%50==0)
		   {
		    nIndicatorLen=IL_LONG;
		   }
		   else if((i+1)%10==0)
		   {
		    nIndicatorLen =IL_MEDIUM1;
		   } 
		   else if((i+1)%2==0)
		   {
		     nIndicatorLen =IL_MEDIUM2;	
		   }
		   else
		   {
	         nIndicatorLen =IL_SHORT;	
		   }
		 nIndPos +=LogLenX/10;
		 dc.MoveTo(nIndPos, nIndicatorLen);
		 dc.LineTo(nIndPos, HRULER_BOTTOM);
		}
	  }

   //A0  1000个点为1英寸
	 LPSTR lpst2={"123456789"};
	 int i,j;
     j=100;  
	 for(i=0;i<9;i++)
	 {
	   dc.TextOut(j,1,lpst2,1);
       lpst2=lpst2+1;
	   j=j+100;
	 }

     LPSTR lpst3={"1011121314151617181920212223242526272829303132333435"};
	 j=1002; 
     for(i=0;i<26;i++)
	 {
		dc.TextOut(j,1,lpst3,2);
        lpst3=lpst3+2;
	    j=j+100;
	 }

  /*//A1  1300个点为1英寸
    LPSTR lpst2={"123456789"};
	 int i,j;
     j=130;  
	 for(i=0;i<9;i++)
	 {
	   dc.TextOut(j,1,lpst2,1);
       lpst2=lpst2+1;
	   j=j+130;
	 }

     LPSTR lpst3={"10111213141516171819202122232425"};
	 j=1302; 
     for(i=0;i<16;i++)
	 {
		dc.TextOut(j,1,lpst3,2);
        lpst3=lpst3+2;
	    j=j+130;
	 }*/

   //西飞500个点为1英寸
     /*LPSTR lpst2={"2468"};
	 int i,j;
     j=120;  
	 for(i=0;i<4;i++)
	 {
	   dc.TextOut(j,1,lpst2,1);
       lpst2=lpst2+1;
	   j=j+120;
	 }

     LPSTR lpst3={"10121416182022242628303234363840424446485052545658606264666870"};
	 j=600; 
     for(i=0;i<31;i++)
	 {
		dc.TextOut(j,1,lpst3,2);
        lpst3=lpst3+2;
	    j=j+120;
	 }*/

   }
 }

⌨️ 快捷键说明

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