CCurveDlg, a Freeware MFC Curve Class
Its appearance is similar to the curves dialog as seen in the Adobe Photoshop. The classes are split up into a document/view architecture.
CCurveWnd, derived from
CWnd, for the visual representation of the curve. This class takes care of drawing and user interaction.
CCurveObject, derived from
CObject for the data representation of the curve. This class holds the curve data, and does all calculation calls, to perform the curve interpolation.
The actual calculation is done with the help of the XlXtrFun.dll. This is actually an Excel extension DLL or XLL, but I have written a wrapper class
CCurveDllImpl for it, so it can easily be used in VC++. For more info regarding this DLL, check their website.
CCurveWnd is simple, just follow the next steps:
- Add the following files to your project workspace:
- CurveWnd.h and CurveWnd.cpp
- CurveObject.h, CurveObject.cpp and CurveObjectDef.h
- CurveDllImpl.h and CurveDllImpl.cpp.
- Copy the XlXtrFun.dll to your project directory
You should also ensure that the 3 cursors (namely,
IDC_ARRBLCKCROSS) are copied over into your rc file and renamed properly.
- Add the following
include statement to your project stdafx.h file
- Then add a
CCurveWnd member to your own
CDialog::OnInitDialog(), you need to create the
CRect(25, 55, 235, 265), this, 2001, true);
Create method is defined as follows:
BOOL Create(LPCTSTR lpszCurveName,
const RECT &rect,
Note: If you set
CreateCurveObj = false and you don't create a curve object manually by calling
, the application may assert.
If you want the
CurveWnd to draw a parabolic curve, you have to add the following code:
CCurveObject* pCurve = m_cCurveWnd.GetCurveObject();
pCurve->m_bParabolic = true;
GetCurveObject method is defined as follows:
Basically that will do the job.
Full description of the API functions is not yet available, I haven't had the time to write it. But I will come up with the first update of the code, so until then just email me if u have problems and questions.
If you have any suggested improvements, please let me know so that I can incorporate them into the next release.