Objective Chart : PART I User’s Guide : Chapter 5 Integration Tutorial
Chapter 5 Integration Tutorial
Introduction
NOTE >> The sample code used in this chapter is available from the Rogue Wave Web site, as explained in “Location of Sample Code” in the Getting Started part.
The Fast Start example in Chapter 4 shows how to create a new application with AppWizard and incorporate an Objective Chart as its main view. In this chapter, you will learn how to integrate Objective Chart into existing Microsoft Foundation Class library (MFC) applications.
You need not be familiar with MFC to read through this tutorial, but it will help if you understand the class library overview. Following the instructions in this tutorial, you can create a dialog to display a chart, integrate a chart window with another window, and use the ComDoc system to link two related documents.
This tutorial has three steps. Each step adds a chart to the Scribble sample program. Steps Two and Three build on the previous steps. However, the functionality introduced with each step is independent of the others, so you can study each step in isolation.
For a hands-on learning experience, copy the Scribble project to a new directory and modify the code following the instructions below. The sample is located at ..\Chart\tutorial\Steps\Step1, within the self-extracting archive file, Stingray Studio Additional Samples.exe, as explained in “Location of Sample Code” in the Getting Started part.
Alternatively, you can simply read along and compile the completed code supplied for each step.
In the text of this tutorial, new lines that you need to add to code segments are highlighted in bold text for easy identification.
NOTE >> The dialog boxes and other images shown in this tutorial were captured using a particular version of Visual Studio and Windows. If you use a different version of Visual Studio or Windows, what you see on your screen will likely be different, but the functionality will be the same.
In Step One: Creating and Displaying the Statistics Chart, statistics about Scribble's strokes are displayed in a chart control in a dialog box. The basic Objective Chart classes SRGraph, SRGraphDisplay, SRGraphTitle, and SRGraphLegend are introduced.
Step Two: Plotting Scribble Data with an X-Y Scatter Chart displays an X-Y scatter chart in the second pane of Scribble's splitter window. This second view of Scribble's data is based on the SRGraphView class. The SRGraphData class is also used.
In Step Three: ComDocs and Document Linking, a secondary (or child) document and view are created to display another X-Y scatter chart. Objective Chart's specialized document class CGraphDoc is used in the second document template. CGraphDoc is based on SECComDoc and contains an SRGraph storage object. An SRGScrollView object provides a view for the graph. For demonstration purposes, the SRGraph data merely duplicates the stroke data contained in the original CScribbleDoc document. Using Objective Chart's ComDoc system, the two documents are linked. When the user changes data values in the chart (by dragging visual objects with the mouse), the corresponding points in the list of strokes change as well.