65.9K
CodeProject 正在变化。 阅读更多。
Home

CCurveDlg - 曲线插值

starIconstarIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIcon

2.75/5 (4投票s)

2001年9月16日

2分钟阅读

viewsIcon

115798

downloadIcon

5342

一个类似Photoshop的曲线对话框。

Sample Image - CurveDlg.gif

引言

欢迎使用CCurveDlg,一个免费的MFC曲线类

它的外观类似于Adobe Photoshop中的曲线对话框。这些类被分成文档/视图架构。

  • CCurveWnd,继承自CWnd,用于曲线的可视化表示。此类负责绘图和用户交互。
  • CCurveObject,继承自CObject,用于曲线的 数据表示。此类保存曲线数据,并执行所有计算调用以执行曲线插值。

实际计算是在XlXtrFun.dll的帮助下完成的。这实际上是一个Excel扩展DLL或XLL,但我已经为此编写了一个包装类CCurveDllImpl,因此它可以很容易地在VC++中使用。有关此DLL的更多信息,请查看其网站

用法

添加CCurveWnd很简单,只需按照以下步骤操作

  1. 将以下文件添加到您的项目工作区
    • CurveWnd.hCurveWnd.cpp
    • CurveObject.hCurveObject.cppCurveObjectDef.h
    • CurveDllImpl.hCurveDllImpl.cpp
  2. XlXtrFun.dll复制到您的项目目录

    您还应该确保将3个光标(即IDC_ARRBLCKIDC_ARRWHITEIDC_ARRBLCKCROSS)复制到您的rc文件中并正确重命名。

  3. 将以下include语句添加到您的项目stdafx.h文件
    #include "resource.h"
  4. 然后向您自己的CDialog类添加一个CCurveWnd成员
    CCurveWnd m_cCurveWnd;

    在您的CDialog::OnInitDialog()中,您需要创建CurveWnd

     m_cCurveWnd.Create("", 
     CRect(25, 55, 235, 265), this, 2001, true);

    Create方法定义如下

    BOOL Create(LPCTSTR lpszCurveName,   //Points to a null-terminated 
                                         //character string that 
                                         //contains the window name
                const RECT &rect,        // The size and position 
                                         //of the window, in client 
                                         //coordinates of pParentWnd
                CWnd* pWndParent,        // The parent window
                UINT nID,                // The ID of the child window
                BOOL CreateCurveObj)     // Set to true if the create 
                                         // function has to
                                         // create a curve object

注意:如果您设置CreateCurveObj = false并且您没有通过调用CCurveWnd::CreateCurveObject(CString strCurve)手动创建曲线对象,则应用程序可能会断言。

如果您希望CurveWnd绘制抛物线,则必须添加以下代码

CCurveObject* pCurve = m_cCurveWnd.GetCurveObject();
pCurve->m_bParabolic = true;

GetCurveObject方法定义如下

CCurveObject* GetCurveObject(); // Returns a pointer to the curveobject

基本上就是这样。

API函数

API函数的完整描述尚不可用,我还没有时间编写它。但是我会尽快发布代码的第一个更新,在此之前,如果您有任何问题,请给我发邮件。

历史

  • v1.0 (2001年9月16日)

    CCurveDlg 首次发布。

计划增强功能

如果您有任何改进建议,请告诉我,以便我可以将其纳入下一个版本。

特别感谢

© . All rights reserved.