zoukankan      html  css  js  c++  java
  • GreenOpenPaint的实现(三)添加标尺

    标尺对于图像处理程序,特别是需要精确测量的程序来说意义很大。这里进行了专门的研究。

    基于现在已经引入的类和定义的变量,主要讲一讲如何调用。
    1、添加放大缩小
    void CGreenOpenPaintDoc::ScaleFactorZoomIn(void)
    {
        if (m_fScaleFactor < ZOOM_MAX)
        {
            m_fScaleFactor = m_fScaleFactor*2;
        } 
    }
     
     
    void CGreenOpenPaintDoc::ScaleFactorZoomOut(void)
    {
        if (m_fScaleFactor > ZOOM_MIN)
        {
            m_fScaleFactor = m_fScaleFactor /2;
        } 
    }
    2、在view中添加添加warpper 
    void CGreenOpenPaintView::OnUpdate(CViewpSenderLPARAM lHintCObjectpHint)
    {
        SetScrollSizes(MM_TEXT,
            CSize(int(m_pDoc->m_image.Width()*m_pDoc->m_fScaleFactor),
            int(m_pDoc->m_image.Height()*m_pDoc->m_fScaleFactor)));
        UpdateRulersInfo(RW_POSITIONGetScrollPosition());
        Invalidate();
    }
     
    void CGreenOpenPaintView::UpdateRulersInfo(int nMessageCPoint ScrollPosCPoint Pos)
    {
        if (!m_pParent)
            return;
     
        CSize  m_ImageSize = CSize(m_pDoc->m_image.Width(),m_pDoc->m_image.Height());
        stRULER_INFO pRulerInfo;
        pRulerInfo.uMessage    = nMessage;
        pRulerInfo.ScrollPos   = ScrollPos;
        pRulerInfo.Pos         = Pos;
        pRulerInfo.DocSize     = m_ImageSize;
        pRulerInfo.fZoomFactor = m_pDoc  ->m_fScaleFactor;
        m_pParent->UpdateRulersInfo(pRulerInfo);
    }
    3、mainframe中添加warpper 
    void CMainFrame::UpdateRulersInfo(stRULER_INFO stRulerInfo)
    {
        m_Rulers.UpdateRulersInfo(stRulerInfo);
    }
     
     
    void CMainFrame::ShowRulers(bool bShow)
    {
        m_Rulers.ShowRulers(bShow);
    }
    注意要把m_ruler添入
    private:
        CRulerSplitterWnd m_Rulers;
    4、重写mainframe 的 oncreateclient事件
    BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs,CCreateContextpContext)
    {
        if (!m_Rulers.CreateRulers(thispContext)) {
            TRACE("rulers创建失败 ");
            return CFrameWnd::OnCreateClient(lpcspContext);
        }
        return TRUE;    
    }
    这个时候标尺出现,只不过由于没有指示量纲,所以没有画刻度
    p.s 注意这个时候,一定要在view创建的时候进行scroll尺度的初始化,否则会assert错误
      CGreenOpenPaintView::CGreenOpenPaintView()
        : m_pParent(NULL)
        , m_pDoc(NULL)
    {
        // TODO: 在此处添加构造代码
        CSize sizeTotal;
        sizeTotal.cx = sizeTotal.cy = 100;
        SetScrollSizes(MM_TEXTsizeTotal);
    }
     
    当导入图片的时候,出现真实标尺。这里是按照厘米这个量纲进行计算的。


    代码

    http://files.cnblogs.com/files/jsxyhelu/GreenOpenPaint2.rar



  • 相关阅读:
    CSS盒子模型
    getContextPath、getServletPath、getRequestURI、request.getRealPath的区别
    MYSQL中的CASE WHEN END AS
    单点登录的精华总结
    git&github
    June 21st 2017 Week 25th Wednesday
    June 20th 2017 Week 25th Tuesday
    June 19th 2017 Week 25th Monday
    June 18th 2017 Week 25th Sunday
    June 17th 2017 Week 24th Saturday
  • 原文地址:https://www.cnblogs.com/jsxyhelu/p/6353619.html
Copyright © 2011-2022 走看看