Simple to Use, Yet Powerful Graphics Classes

Environment: [VC6, NT4 SP5, Windows 95b/98]

In engineering applications it is necessary to have some graphics functions which can draw graphics using dynamic engineering data. The following simple classes provide such functions which have been implemented using SDK rather than MFC.


  • Linear and logarithmic Cartesian coordinate system
  • 11 types of symbolic markers
  • 6 types of bar and pie shapes
  • Support Memory Device Context drawing
  • Support printing
  • Any direction text alignment and output
From 1992 to 1993, I wrote a graphical library for the Basin Modeling project (PC version) Using Borland C++, and added the CBarLine class based on the VBChart example of Visual C++ 1.0 (16 bit) and the CPie class in 1994. I ported part of the code to Unix using X-Windows Library in 1994. I've been intending to update the code from Win16 API to Win32 API, but have found it very difficult to justify the time. I tried to do it in 1995 in the database project using VC++ 2.0, but only had beginning no ending. From 1996 to 1998, I involved the 3D reservoir modeling project using OpenGL on Windows NT, and the real-time power plant simulation project on Unix in 1999. Consequently, I got nothing for this. This year I am involving to write a real-time simulation application using VC++ 6.0 on Windows NT and finally get round to do it. However, the provided classes, which have been rewritten using Win32 API completely, only implement part of the original graphical library except CRealTime. Due to time constraints, graphic edit functions, the Gaussian (earth) coordinate system and its conversion with Cartesian coordinate system, and map digitizing have not been rewritten. Therefore, those features are not included in the above classes.

You are free to use or modify these classes and to use them in any of your applications. But I make no guarantees about these classes suitability for use. If there is any problem with anything I wrote, I will certainly try to help solve it.

Source Code

  • Graphics.h and Graphics.cpp: property definition and drawing framework description.
  • Scatter.h: template based class to implement the simplest plot under the linear and logarithmic Cartesian coordinate system
  • .
  • BarLine.h and Pie.h: template based classes to implement the simplest chart.

Demo Project

The GRDemo, which is an MFC MDI application, demonstrates how to use classes mentioned above. It uses two DocTemplates and two views (one is CScrollView and the other is CView).

The former view shows some features of CLinear, CXLogYLinear, CXLinearYLog, and CXlogYlog classes. From the File menu, you can test open this view, print preview, and print the map. From the Map menu, you can select one map, two maps, or four maps with a view. From the Type menu, you can select linear, or logarithmic coordinate system. The Property menu includes grid, boundary, legend, title, memory drawing, and back color properties. The Zoom menu demonstrates rectangle and random zoom in, fixed scale zoom in or out (+ or -), and drag maps (two scrollbars move at the same time).

The latter view shows some features of CBarLine and CPie classes, It only displays one map in each view and no scroll capability.

CRealTime class uses some complex algorithms and will be demonstrated in RTDemo project.

About the Author

I am a senior software engineer for TechComm Simulation Pty Ltd., Sydney, Australia, where I specialize in Client/Server and TCP/IP programming on Unix and Windows NT. My e-mail address is


Download demo project - 47 Kb
Download source - 16 Kb


Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Learn How A Global Entertainment Company Saw a 448% ROI Every business today uses software to manage systems, deliver products, and empower employees to do their jobs. But software inevitably breaks, and when it does, businesses lose money -- in the form of dissatisfied customers, missed SLAs or lost productivity. PagerDuty, an operations performance platform, solves this problem by helping operations engineers and developers more effectively manage and resolve incidents across a company's global operations. …

  • Today's agile organizations pose operations teams with a tremendous challenge: to deploy new releases to production immediately after development and testing is completed. To ensure that applications are deployed successfully, an automatic and transparent process is required. We refer to this process as Zero Touch Deployment™. This white paper reviews two approaches to Zero Touch Deployment--a script-based solution and a release automation platform. The article discusses how each can solve the key …

Most Popular Programming Stories

More for Developers

RSS Feeds