Simple to Use, Yet Powerful Graphics Classes | CodeGuru

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. Features Linear and logarithmic Cartesian coordinate system 11 types of symbolic markers 6 types […]

Written By
CodeGuru Staff
CodeGuru Staff
Jul 23, 2000
3 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

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.

Features

  • 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.

Advertisement

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.

Downloads

Download demo project – 47 Kb

Download source – 16 Kb

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.