Introduction
Movable and resizable graphics is presented in the
form of several programs, one library (DLL file) and some documents.
MoveGraphLibrary.DLL the library itself. Classes are
described in MoveGraphLibrary_Classes.doc. It is the current
document.
TuneableGraphics.EXE demonstrates the use of movable / resizable objects in
absolutely different areas. Description
of the program is in TuneableGraphics_Description.doc.
Test_MoveGraphLibrary.zip contains
the whole project, demonstrating the use of MoveGraphLibrary (DLL file is
included). This application demonstrates
the use of some classes from the library and the design of new class of movable
/ resizable graphical objects. The
description of the program is in Test_MoveGraphLibrary_Description.doc.
NewDesignParadigm.doc an article about the ideas and consequences of using such graphics in
complicated programs.
List of classes
All links
Application http://levd.members.winisp.net/TuneableGraphics.zip
TuneableGraphics application and its description with a lot of
pictures.
Test program http://levd.members.winisp.net/Test_MoveGraphLibrary.zip
Includes the whole project of this sample program
together with the detailed explanation of all the steps to design and use
classes of movable / resizable graphical objects. Another DOC file contains the description of
classes included into MoveGraphLibrary.dll.
Library http://levd.members.winisp.net/MoveGraphLibrary.zip
Library and the description of classes included into
it (current document).
Article http://levd.members.winisp.net/NewDesignParadigm.doc
DOC files (with one exception) are also available in
the form of HTM
http://levd.members.winisp.net/Test_MoveGraphLibrary_Description.htm
http://levd.members.winisp.net/MoveGraphLibrary_Classes.htm
http://levd.members.winisp.net/NewDesignParadigm.htm
class FullGrArea
This is the general class for plotting of y(x) or
parametric functions. The whole area
consists of the main plotting area (PureGrArea),
two scales (NumScale - one horizontal and one vertical) and title (Title). The main
line of each scale can be placed either on the border of the main plotting area
or outside; ticks and numbers of the scale can be placed on both sides of its
line, so they can appear either outside the main plotting area or inside. Title can be placed anywhere. The objects of the FullGrArea class can be made movable and resizable by adding
them to Mover.
In the current version the parameters of any FullGrArea object can be changed through calling three different
forms (one for each scale and the third one deals with the main area parameters
and the positioning of the auxiliary parts in relation to main area).
Public constructors
FullGrArea (Rectangle rc, area of the real plotting
Side sideHsc, side of horizontal scale
double fL, value on the left border
double fR, value on the right border
int
nVerGridLines, minimum number of vertical grid lines
Side sideVsc, side of vertical scale
double fT, value on the top border
double fB, value on the bottom border
int
nHorGridLines) minimum number of horizontal grid
lines
FullGrArea (Rectangle rc,
Side sideHsc, side of horizontal scale
double fL, value on the left border
double fR, value on the right border
double fXStep, grid step along horizontal scale
Side sideVsc, side of vertical scale
double fT, value on the top border
double fB, value on the bottom border
double fYStep) grid step along vertical scale
Side parameters can be one of:
enum
Side { W, N, E, S }
FullGrArea (RegistryKey regkey, string
str)
Restores the FullGrArea
that was previously saved into Registry.
To restore correctly the str parameter
must be the same as was used in IntoRegistry().
Public properties
double AnchorTitleXcoef Gets or sets the coefficient that describes the horizontal position
of the title’s center relative to the width of the plotting area.
0 means that the center will be on the left border, 1
– on the right border. Negative values
will put the title to the left of the plotting area, values bigger than 1 – to
the right.
double AnchorTitleYcoef Gets or sets the coefficient that describes the vertical position
of the title’s center relative to the height of the plotting area.
0 means that the center will be on the top border, 1 –
on the bottom border. Negative values
will put the title above the plotting, values bigger than 1 – below.
Rectangle Frame Gets the unified area of the plotting
area and those of additional areas (both scales and title) which are shown.
NumScale HorScale Gets the horizontal scale.
Side HorScaleSide Gets the horizontal scale side.
PureGrArea MainArea Gets the real plotting area.
bool ShowHorScale Gets or sets the flag to show horizontal scale.
bool ShowVerScale Gets or sets the flag to show vertical scale.
bool ShowTitle Gets or sets the flag to show title.
int SpaceToHorScale Gets or sets the space between plotting area and the line of
the horizontal scale.
int SpaceToVerScale Gets or sets the space between plotting area and the line of
the vertical scale.
Title Title Gets the title.
Point TitleAnchorPoint Gets or sets the title central point.
NumScale VerScale Gets the vertical scale.
Side VerScaleSide Gets the vertical scale side.
Public methods
FullGrArea Copy (FullGrArea
src) Constructs the identical copy of another graphical
area.
void CopyView (FullGrArea
src) Copies all view parameters from another graphical
area.
void DefineContour () Defines contour used for moving and resizing.
void Draw (Graphics grfx) Draws the main plotting area and
additional parts (scales and title), if they must be shown. The main area is the first to be drawn, so
everything else can be shown on top of it.
The main line of the scale can not move into the main area, but ticks,
numbers and labels can.
void FlipHorScale () Flips the horizontal scale to the opposite side of the
plot.
void FlipVerScale () Flips the vertical scale to the opposite side of the plot.
bool InsideHorScale (Point pt) Tests if the point is inside
horizontal scale.
bool InsideMainArea (Point pt) Tests if the point is inside main
plotting area.
bool
InsideSensitive (Point pt) Tests if the point is inside full sensitive area, that includes real plotting area plus scales and title,
but only if these additional parts are shown.
bool InsideTitle (Point pt) Tests if the point is inside title.
bool InsideVerScale (Point pt) Tests if the point is inside vertical
scale.
void
IntoRegistry (RegistryKey regkey, string str) Saves into Registry.
Method of saving information to the Registry is
closely related to the construction from Registry. To restore the same object from Registry use
constructor with the same str parameter.
void Move (int cx, int cy) Moves the full object on the defined number of pixels from
current position.
bool
MoveContourPoint (int i, int cx, int cy, Point ptM, MouseButtons
mb)
Moves one node of the contour on the
defined number of pixels from current position. Position of the mouse (ptM) and the mouse
button which was used to capture the contour point can be useful for some
movements.
void ParametersDialog
(Form formOwner, The form from which this dialog is called
OnParamForm onChanged, the
function to be executed on change of any parameter
OnParamForm onClosed, the function to be executed on
closing the parameter’s dialog
string strTitle) title of the parameter’s dialog
This is the way to open the standard dialog for
changing the parameters of the main area, for positioning of both scales and
title. Usually onChanged is doing nothing else but Invalidate() of the form in
which FullGrArea is used, and two last parameters can be set to
null. (Look into Test_MoveGraphLibrary
for an example.)
There
is a set of methods to draw y(x) function.
Methods can use:
void DrawYofX (Graphics grfx, Pen
pen, double [] fx, double
[] fy, int nDot,
SegmentLocation
nSegmentToShow)
Draws function y(x) defined by two
arrays and using the first nDot values from these arrays.
The graph is shown as a consequence of straight
segments. The last parameter defines for
each segment if it must be shown or not depending on the position of its end
points:
SegmentLocation
.Fully_Inside both points must be inside the
plotting area
SegmentLocation
.Partly_Inside at least one point is inside the
plotting area
SegmentLocation
.Any_Location points can be anywhere
void DrawYofX (Graphics grfx, int
iPen, double [] fx, double
[] fy,
int
nDot, SegmentLocation nSegmentToShow)
Draws function y(x) using one of
inside pens.
void DrawYofX (Graphics grfx, Pen
pen, ValuesOnBorders valBorders,
double
[] fx, double [] fy,
int
nDot, SegmentLocation nSegmentToShow)
Draws function y(x) using the border
values passed as parameters.
void DrawYofX (Graphics grfx, int
iPen, ValuesOnBorders valBorders,
double
[] fx, double [] fy,
int
nDot, SegmentLocation nSegmentToShow)
Draws function y(x) using the border
values passed as parameters.
void DrawYofX (Graphics grfx, Pen pen,
Delegate_DblOfDbl processFunc,
SegmentLocation
nSegmentToShow)
Draws function y(x) passed as a
delegate.
delegate double Delegate_DblOfDbl
(double fArg)
void DrawYofX (Graphics grfx, int
iPen, Delegate_DblOfDbl processFunc,
SegmentLocation
nSegmentToShow)
Draws function y(x) passed as a
delegate.
void DrawYofX (Graphics grfx, Pen
pen, Delegate_DblOfArray processFunc,
double
[] fParam, SegmentLocation nSegmentToShow)
Draws function y(x) passed as a
delegate using array of parameters.
delegate double Delegate_DblOfArray
(double fArg, double
[] param)
void DrawYofX (Graphics grfx, int
iPen, Delegate_DblOfArray processFunc,
double
[] fParam, SegmentLocation nSegmentToShow)
Draws function y(x) passed as a
delegate using array of parameters.
void DrawYofX (Graphics grfx, Pen
pen, ValuesOnBorders valBorders,
Delegate_DblOfDbl
processFunc, SegmentLocation nSegmentToShow)
void DrawYofX (Graphics grfx, int
iPen, ValuesOnBorders valBorders,
Delegate_DblOfDbl
processFunc, SegmentLocation nSegmentToShow)
There
are methods to draw parametric functions.
void
DrawParamFunc (Graphics grfx, Pen pen,
Delegate_DblOfDbl calcX, delegate
to calculate x(p)
Delegate_DblOfDbl calcY, delegate
to calculate y(p)
double fParamFrom, parameter’s starting value
double fParamTo, parameter’s end value
double fParamStep) parameter’s step
void
DrawParamFunc (Graphics grfx, int iPen,
Delegate_DblOfDbl calcX, delegate
to calculate x(p)
Delegate_DblOfDbl calcY, delegate
to calculate y(p)
double fParamFrom, parameter’s starting value
double fParamTo, parameter’s end value
double fParamStep) parameter’s step
class PureGrArea
Public constructor
PureGrArea (Rectangle rc) area of the real plotting
Public properties
Rectangle Area Gets or sets the plotting area.
Color BackColor Gets or sets the area’s back color.
Board Board Gets or sets the area’s transparency.
Board can be one of:
enum
Board { Transparent, Opaque }
Color BorderColor Gets or sets the area’s border color.
Border’s width is always 1.
DashStyle BorderDashStyle Gets
or sets the style for area’s borders.
Color HGridColor Gets or sets the horizontal grid color. Lines’ width is always 1.
DashStyle HGridDashStyle Gets
or sets the style for horizontal grid.
static int MinSize Gets the minimum size of the
area. Minimum size (now it is 50) is set
to avoid accidental disappearence of the area while resizing it.
bool PenMove
(int iFrom, int
iTo) Changes the position of the pen stored inside.
Pen [] Pens Gets or sets the pens stored inside;
there can be up to 8 pens.
bool [] ShowBorders Gets or sets the flags to show
borders. The order of flags is left,
top, right, bottom.
bool ShowHGrid Gets or sets the flag to show horizontal grid.
bool ShowVGrid Gets or sets the flag to show vertical grid.
Color VGridColor Gets or sets the vertical grid color. Lines’ width is always 1.
DashStyle VGridDashStyle Gets
or sets the style for vertical grid.
Public methods
void CopyView (PureGrArea
src) Copies all view parameters from another area.
void Draw (Graphics grfx, int []
cx_VGrid, int [] cy_HGrid)
Draws area. Grids are
drawn on coordinates sent through the parameters, but only if they have to be
shown (according with the flags).
void FromRegistry (RegistryKey regkey, string
strAdd)
void
IntoRegistry (RegistryKey regkey, string strAdd)
Pair of methods to save into and restore from
Registry. The information will be saved
in two lines:
“PureArea” + strAdd all the parameters except
array of pens
“PurePens” + strAdd the array of pens
void Move (int cx, int cy) Moves the area on the defined number of pixels from current
position.
There is a set of methods to draw y(x)
functions and parametric functions. They
use the same set of parameters as the draw functions for FullGrArea. If PureGrArea
is used as a part of FullGrArea, then these methods will be called
automatically.
void DrawYofX (Graphics grfx, Pen
pen, ValuesOnBorders valBorders,
double
[] fx, double [] fy, int
nDot, SegmentLocation nSegmentToShow)
void DrawYofX (Graphics grfx, int
iPen, ValuesOnBorders valBorders,
double
[] fx, double [] fy, int
nDot, SegmentLocation nSegmentToShow)
void DrawYofX (Graphics grfx, Pen
pen, ValuesOnBorders valBorders,
Delegate_DblOfDbl
processFunc, SegmentLocation nSegmentToShow)
void DrawYofX (Graphics grfx, int
iPen, ValuesOnBorders valBorders,
Delegate_DblOfDbl
processFunc, SegmentLocation nSegmentToShow)
void DrawYofX (Graphics grfx, Pen
pen, ValuesOnBorders valBorders,
Delegate_DblOfArray
processFunc, double [] fParam,
SegmentLocation
nSegmentToShow)
void DrawYofX (Graphics grfx, int
iPen, ValuesOnBorders valBorders,