SRGraphPosition Class Overview

The SRGraphPosition class is a communication class which interrogates the graphs data and component structures and returns information regarding them based upon the x,y coordinate position supplied. Very often this coordinate will be the direct input from the mouse or other pointer device.

Once a graph position object has been constructed it will look at the graph data and the components in the m_ComponentList member of the parent graph to ascertain exactly where the point was in relation to data and displays. Information is returned via the SRGraphPosition internal data members which must be interrogated according to strict rules. The SRGraphPosition class will set certain flags internally and you must read those flags using the provided member functions. For example if the user clicks a mouse button in a display you can use SRGraphPosition to find out what index and what group is being displayed at the point in question. You can ascertain also its numerical value along the X and Y axes. You can also discover what kind of selection can be made if the user is beginning a drag-box selection procedure.

After the initial construction which should be done using the special constructor overload you may ask what data is available. The routine HasIndex() will return TRUE only if an index was successfully calculated from the point. If the answer was TRUE then the index can be retrieved using the GetIndex function.. Similarly there are HasGroup(), HasValueX() and HasValueY() member functions and complimentary get and set functions for all the relavent data members.

A selection type is returned which is different according to the graph type available. The standard type are horizontal, for ordinary x,y classic charts. Vertical for the horizontal bar types, Both for scatter graphs which may have an arbitrary rectangular selection for zooming and Circular for web charts. Because the process may be working on one of your own graph types a routine is also provided which allows your virtual override of the custom type routine to enter a selection type suitable for your own graph.

Because graph displays may be made to overlay one another transparently the SRGraphPosition class holds a special pointer variable which serves a dual purpose. If the mouse point is found to be in a single SRGraphDisplay objects visible scope then the pointer will be directed at the object in question. This means that supplementary data may be gained by interrogating the display item itself If however the point is found to be in more than one display object a list of the displays is created and the individual displays within that list may be examined by de referencing them with a zero based index. In this case the pointer will be directed to a CPtrList object that can be manipulated in the normal way should it be required. An error checked routine is provided to retrieve either the list or the single pointer.

Because the automatic positioning and scaling systems in SRGraph are so complex and dynamic you can never really guarantee to be in a specific place in the data structures until all activity has stopped. Luckily the activity within SRGraph and its components takes place almost exclusively at draw time. After the drawing is finished the components have the "stain" of all the automatic positioning and dynamic movement left intact. Therefore SRGraphPosition can use the m_DisplayRect member in a display component to ascertain the exact position, scale and state of the graphs data. The use of SRGraphPosition during a draw cycle is a pointless waste of time and while it will not crash the computer or destroy data it will not return accurate results.

The accuracy of positioning and data value gathering in SRGraph and by SRGraphPosition is mainly dependant on the screen resolution and the size of the graph data panel being interrogated. If the range of data values goes from 0 to 10,000 and the m_DisplayRect final size is 200 pixels high after the draw cycle finishes then the position accuracy will only be able to deliver a value within 50 units of the real value. Likewise if the number of data items is more than the number of pixels across the m_DisplayRect member then it will not be possible to pick out a single group or index from the position of the mouse.