This article was contributed by Paul Barvinko
CGraphView is a class that provides multiplot 2D data visualization. It is capable of simultaneous drawing for up to 32 2D plots. CGraphView class is derived from CView MFC class and could be used as base class for different kinds of 2D data plot views. Features supported: -Autoscale -Zooming -Fit width, height and page -Mouse coordinates tracing -Interactive add, remove and edit points -Ability to add and display interactively up to 15000 points per second (depends on the speed of the computer)
Class interface provides several groups of functions: Graphs manipulation routines: int AddGraph(COLORREF newColor = 0, char* title = "", BOOL bInvalidate = TRUE); Function adds new graph to the view. Returns graph index if successful or -1 if not. If bInvalidate flag is set then view will be updated. int RemoveGraph(int index, BOOL bInvalidate = TRUE); Function removes graph from collection. int UpdateGraph(int index, BOOL bInvalidate = TRUE); Function updates graph information and view, if bInvalidate flag is set. Useful after collective operations with hidden graph. CGraphProp* GetGraph(int index); Function returns properties for the given graph or NULL in case of error. CGraphProp* GetFirstGraph(int* index); CGraphProp* GetNextGraph(int* index); These functions are used to enumerate through all existing graphs in the view. void SetGraphFlags(DWORD new_flags, BOOL bRedraw); DWORD GetGraphFlags(); These functions are used to get or set graph view flags. Flag value is an OR'ed combination of:
#define GRAPH_AUTOSCALE 0x00000001 // use autoscale when adding new points #define GRAPH_SQUAREPOINTS 0x00000002 // Draw rectangles around points #define GRAPH_SHOW_TOOLTIP 0x00000004 // Show coordinates as a ToolTip when moving mouse #define GRAPH_DRAW_AXIS 0x00000008 //Draw axis
There are several steps that you should do in order to use this class in your application: 1. Include all graph files (except grres.rc) into your project. 2. Open grres.rc and copy following resources into your project resources: IDD_CHANGE_TITLE dialog IDD_GRAPH_AXISPROPS dialog IDD_GRAPH_GENPAGE dialog IDD_GRAPHS dialog IDD_GRAPHS_PROPPAGE dialog IDD_POINT_EDIT dialog IDR_GRAPH_PROPS menu IDR_PVIEW_RBMENU menu IDR_PVIEW_RBMENU_EMPTY menu 4. Derive your view class from CGraphView - and off we go!
Download demo project - 107 Kb
Download source - 70 Kb
Latest updates and information could be found here.
Date Posted: August 7, 1999
Add Comment
INSTANT EXPERTS!Savvy IT Pros report on SupportSource. Take a look inside the largest vault of multi-vendor computing specs ever assembled. Click here for an In-depth Report,. For tons of Windows technology resources, check out the Windows Programming directory. Searching the Web for tech topics just got better withTechCrawler where all results come only from popular technical sites. WINNER!!! Congratulations to James Hole, of New Mexico! The grand prize winner of EarthWeb's Flatten the Obstacles Sweepstakes and now a proud Hummer(R) owner.
WINNER!!! Congratulations to James Hole, of New Mexico! The grand prize winner of EarthWeb's Flatten the Obstacles Sweepstakes and now a proud Hummer(R) owner.