2D-Graphik-Control

Version 1

Copyright © 1999, by Jürgen Eder

 

Juergen.Eder@gmx.de

 

 

Date: 20. Feb. 2005

 

 

 

Grafik1

 

Via this 2D-Graphic-Control equations (for example: sin(x) ) or truth tables can quite simply drawn. In one coordinate system any number of equations and truth tables – also mixed – are possible.

 

 

Content

License

Properties Dialog

Properties

Appearance

BackColor

BorderStyle

Grid

XText

YText

XMaximum

XMinimum

YMaximum

YMinimum

XAutoDelta

YAutoDelta

Color

XDelta

YDelta

MMTwipsModus

BFont

WFont

BFontColor

BFontHeight

WFontHeight

BFontBold

BFontItalic

WFontBold

WFontItalic

WFontTransparent

Function

FunctionColor

Separator

TableFile

XAxisMode

YAxisMode

TableDrawMode

TableLinesDontUse

TableColAsXAxis

TableColAsYAxis

TableXFormula

TableYFormula

Functions

AddFunction

DeleteFunction

ResetGraph

AddTable

DeleteTable

AddTableEntry

AddTableFromFile

ShowPropertyPage

Copy

UserDraw

 

License

This version is FREEWARE. You can use it on your own risk.

 

Properties Dialog

 

Grafik2

In this dialog you can setup the most important parameters (for x and y axis separately):

 

The next picture show a small example (installed with the control):

Grafik3

Properties

Appearance

Syntax

short Appearance

Description

Draw a box around the output. This property depends also from BorderStyle!

 

Appearance

BorderStyle

Description

0

0

no box

1

0

3D box

0

1

2D box (only a black bounding box)

1

1

3D box

BackColor

Syntax

COLORREF BackColor

Description

Change the background color. COLORREF is a RGB value.

BorderStyle

Syntax

short BorderStyle

Description

Set the look of the bounding box. It depends also from Appearance.

Appearance

BorderStyle

Description

0

0

no box

1

0

3D box

0

1

2D box (only a black bounding box)

1

1

3D box

 

Grid

Syntax

BOOL Grid

Description

TRUE

Draw some dashed lines over the output area

FALSE

Draw only the divider near the x/y axis

The divider of the grid will be set by XDelta and YDelta property. Also the divider may be calculated by the control if XautoDelta and/or YAutoDelta are set to TRUE.

XText

Syntax

char *XText

Description

Caption of x axis. This is an optional setting.

YText

Syntax

char *YText

Description

Caption of the y axis. This is an optional setting.

XMaximum

Syntax

double XMaximum

Description

Maximum value of the x axis

 

XMinimum

Syntax

double XMinimum

Description

Minimum value of the x axis

 

YMaximum

Syntax

double YMaximum

Description

Maximum value of the y axis

YMinimum

Syntax

double YMinimum

Description

Minimum value of the y axis

XAutoDelta

Syntax

BOOL XAutoDelta

Description

If TRUE, the x divider will be automatically calculated by the control.

YAutoDelta

Syntax

BOOL YAutoDelta

Description

If TRUE, the y divider will be automatically calculated by the control.

Color

Syntax

COLORREF Color

Description

Color of the coordinate system. COLORREF is a RGB value.

XDelta

Syntax

double XDelta

Description

Divider of the x axis for the grid.

Note

Has no effect if XAutoDelta is set to TRUE

YDelta

Syntax

double YDelta

Description

Divider of the y axis for the grid

Note

Has no effect if YAutoDelta is set to TRUE

MMTwipsModus

Syntax

BOOL MMTwipsModus

Description

Experimental, do not use

BFont

Syntax

char *BFont

Description

Font name for coordinate system

Note

To label the coordinate system you can use two fonts:

- optional caption of x- and y-axis: BFont

- for labeling divider or grid: WFont

The divider will be always labeled!

WFont

Syntax

char *WFont

Description

Font name for divider and / or grid

Note

To label the coordinate system you can use two fonts:

- optional caption of x- and y-axis: BFont

- for labeling divider or grid: WFont

The divider will be always labeled!

BFontColor

Syntax

COLORREF BFontColor

Description

Color of coordinate system caption

BFontHeight

Syntax

short BFontHeight

Description

Font height of coordinate system caption

WFontHeight

Syntax

short WFontHeight

Description

Font height of divider labels

BFontBold

Syntax

BOOL BFontBold

 

TRUE

fat

FALSE

normal

Description

Font option for the coordinate system caption

BFontItalic

Syntax

BOOL BFontItalic

 

TRUE

italic

FALSE

normal

Description

Font option for the coordinate system caption

WFontBold

Syntax

BOOL WFontBold

 

TRUE

fat

FALSE

normal

 

Description

Font option for the divider labels

WFontItalic

Syntax

BOOL WFontItalic

 

TRUE

italic

FALSE

normal

Description

Font option for the divider labels

WFontTransparent

Syntax

BOOL WFontTransparent

 

TRUE

Background will not changed (transparent mode)

FALSE (default)

Background will be cleared before writing text

 

Function

Syntax

char *Function

Description

Any mathematical function will be accepted e.g. "1/x*sin(x)" is valid property.

 

Only one function can be set as a property all other functions must be set by the methods of this control. The control set the id number of this function to 0.

 

FunctionColor

Syntax

COLORREF FunctionColor

Description

Color for the function with the id number 0. (see above: Function)

 

Separator

Syntax

char *Separator

Description

With the function AddTableFromFile you can load text files which includes X-Y values. But before you can load a file with AddTableFromFile you must set the separator character. This can be a semicolon, a comma, a tab, ...

Note

The control will use only the first character of the given string

 

TableFile

Syntax

char *TableFile

Description

File name of a text file with x-y values. Every line with a X-Y pair in the file generate a new entry in the truth table. The separator character should set before with the property: Separator. The control set the identifier of this truth table to 0. See also: AddTable

 

XAxisMode

Syntax

short XAxisMode

Description

Position of the x axis

Mode

X Axis

0 (default)

normal

1

always at bottom

2

always at top

 

 

YAxisMode

Syntax

short YAxisMode

Description

Position of the y axis

Mode

Y Axis

0 (default)

normal

1

always at the right side

2

always at the left side

 

TableDrawMode

Syntax

short TableDrawMode

Description

Drawing mode of the truth table

Mode

Description

0 (default)

normal (every point will be merged by a line with the next point)

1

draw only points

 

TableLinesDontUse

Syntax

long TableLinesDontUse

Description

The control read over this number of lines if it read a text file. (for: AddTableFromFile)

TableColAsXAxis

Syntax

long TableColAsXAxis

Description

Row of X-Axis if there are more rows in the file (for: AddTableFromFile)

TableColAsYAxis

Syntax

long TableColAsYAxis

Description

Row of Y-Axis if there are more rows in the file (for: AddTableFromFile)

TableXFormula

Syntax

char *TableXFormula

Description

Formula to calculate the x axis if the ocx read a truth table from a text file.This means, every x value will be first converted by this formula. (for: AddTableFromFile)

TableYFormula

Syntax

char *TableYFormula

Description

Formula to calculate the y axis if the control read a truth table from a text file.This means, every y value will be first converted by this formula. (for: AddTableFromFile)

Functions

AddFunction

Syntax

void AddFunction(short id, char *function, COLORREF color);

 

Parameter

Description

id

any number (1...), the id: 0 is reserved by the property “Function”

function

mathematical function, e.g. "1/x*sin(x)"

color

color of this function

Description

A mathematical function will be calculated and immediately drawn.

DeleteFunction

Syntax

void DeleteFunction(short id);

 

Parameter

Description

id

ID (1...), which was used in "AddFunction"

Description

The function with the selected ID number will be deleted.

ResetGraph

Syntax

void ResetGraph(void);

Description

All functions and all truth tables will be deleted

AddTable

Syntax

void AddTable(short id, char *name, COLORREF color);

 

Parameter

Description

id

any number (1...), the id: 0 is reserved by the property “TableFile”

name

any name for the truth table

color

color of this graph

Description

A new truth table will be created. The x-y values can be set after.

DeleteTable

Syntax

void DeleteTable(short id);

 

Parameter

Description

id

any ID (1...), which was set in "AddTable()"

Description

Delete the truth table with the selected ID number.

AddTableEntry

Syntax

void AddTableEntry(short id, double x, double y);

 

Parameter

Description

id

any ID (1...), which was set in "AddTable()"

x

X value

y

Y value

Description

With this function you set one x/y pair into the selected truth table (selection by the the ID number)

Note

The control don't sort the values. All values are shown in the order they are added into the truth table.

AddTableFromFile

Syntax

void AddTableFromFile(char *filename, short id, char *name, COLORREF color);

 

Parameter

Description

filename

file name

id

any ID (1...)

name

name of the truth table

color

color of the new graph

Description

A new truth table will be created and all x/y pairs will be read from the text file (every line there must be one x-row and one y-row). You should set a separator character before with the property "Separator".

ShowPropertyPage

Syntax

void ShowPropertyPage(void);

Description

Show the property page

Copy

Syntax

void Copy(void);

Description

Copy the graphic as a bitmap into the clipboard

UserDraw

Syntax

void UserDraw(long HDC, long x, long y, long width, long height);

 

Parameter

Description

HDC

Graphic device handle from Windows API

x

x position

y

y position

width

width

height

height

Description

Use this in your draw function in SDI and MDI applications (e.g. in OnDraw() in MFC apps)