An Introduction to Numerical Methods in C++, Revised Edition

A7: Drawing a function

A7 Drawing a function

Each application will require a few functions peculiar to itself. In each case we therefore define a class derived from TScreen to contain these functions. In order to draw a function, as we did in 15.2.5, we first include the header file screen.h, then define a function type:

typedef double(*func)(double);

The derived class we take to be:

class TFuncScreen : public TScreen {private:      void SetFuncRange();public:      TFuncScreen(LPSTR ATitle) : TScreen(NULL, ATitle) { };      void SetScreen(RECT&, func);      void DrawFunc(HDC, func, COLORREF);      virtual void Paint(HDC PiantDC, PAINTSTRUCT &PaintInfo);};

It contains a private function SetFuncRange which, with the aid of an input dialogue box, determines the interval [x1o, xhi], over which the function is to be examined, and hence the values TopLeft.x and BottomRight.x:

void  TFuncScreen: :SetFuncRange(){      char Buffer [20];      strcpy(Buffer, " ");<a name="851"></a><a name="page512"></a>      float xlo, xhi;      if(GetApplication()->ExecDialog            (new TInputDialog(this, "Input Interval",      "Enter XLO XHI:", Buffer,      sizeof(Buffer) ) ) == IDOK)            sscanf(Buffer, "%f %f", &xlo, &xhi);      TopLeft.x = double(xlo); ...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Plating and Coating Fixture Services
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.