I have an abstract class WaveBase, and derived concrete classes TimeWave and FrequencyWave, which hold time or frequency waveform data.
I'm using MFC doc/view. The document holds a WaveBase* called pWave.

I need to draw graphs of the data, but the different types of data are rendered differently.

WHere there is a TimeWave already displayed, on redraw nothing should happen. Where pWave has been transformed from a TimeWave to a FrequencyWave, on redraw a new graph should be displayed and the axes recalculated and autoscaled to the new data.

My problem is finding a suitable OO design to acheive this, without using RTTI/dynamic casts.

So far, I have an abstract class GraphBase, and derived concrete classes TimeGraph and FrequencyGraph. The view class holds a GraphBase* called pGraph.

I am using the visitor pattern to recover the lost type info for pWave, so that the appropriate graph type can be created, and drawn appropriately using polymorphism (not shown here).

My current implementation for CView::OnDraw is:
GraphFactory gf; //WaveBase visitor
pWave->Accept(gf);

where
Code:
 class GraphFactory{
void visitTimeWave(TimeWave* ) // delete pGraph, create new TimeGraph, autoscale axes
void VisitFrequencyGraph(FrequencyWave* ) // delete pGraph, create new FreqGraph, autoscale axes
};
However, the creation (or not) of a new graph type should also depend on the previous graph type. ie if a TImeWave is being displayed on a TImeGraph, on redraw nothing should happen (as it is currently, the axes are redrawn each time because a new graph is created on each redraw - I do not want this to happen). But if a the TimeWave has been transformed to a FrequencyWave then it should be redrawn as a frequency graph, and axes be autoscaled to the new data.

Note, there is an Axes object which holds the axes limits.

I can see a way to do it using visitors for the graph AND the wave, but this becomes VERY clumsy. I would have to have a TimeGraphFactory and a FreqGraphFactory.

Really I want to be able to have a function which behaves as shown below, only in my case the type info has been lost:
UpdateGraph(TimeWave, TimeGraph) // do nothing
UpdateGraph(TimeWave, FreqGraph) // new TimeGraph, autoscale axes etc
UpdateGraph(FreqWave, TimeGraph) // new FreqGraph, autoscale axes etc
UpdateGraph(FreqWave, FreqGraph) // do nothing

I'm sure there must be a 'standard' solution to this problem, and I would be extremely grateful if anyone could point me in the right direction.

As I have said before, I can do it 'neatly' creating a new graph using the visitor pattern and type of the wave to be displayed, but I ALSO need to use the previous type of the graph to decide whether to make a new object or not.

Thanks

Jon