Simple to Use, Yet Powerful Graphics Classes


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

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 yuantuh@techsim.com.au.


Download demo project - 47 Kb
Download source - 16 Kb


  • You must have javascript enabled in order to post comments.

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

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date