We decided that the WGReconnectDataSet method is not going to work with contour plots, because the WGContourPlot method does too much pre-processing of the contour plot data, pre-processing that the WGReconnectDataSet method doesn't do.
An alternative method is to delete the old contour plot object, define your new data, then create a new contour plot object. You can add new contour plot objects to the graph if you place them between the WGPreAddGraphObject and WGPostAddGraphObject methods. You can skip the WGDeletePlotBitmap and WGRedrawGraph calls.
Something like:
void CContourDView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
static LONG nCount = 1;
CContourDDoc* pDoc = GetDocument(); // get document
bool bitmapresult = false;
if (!pDoc)
return;
if (!pGraph->WGIsGraphValid ())
return;
WGStart();
// get datasets from document
QCStaticData * pDataSet1 = NULL;
// temp datasets
QCStaticData * pTemp1= pDoc->pContourData;
// create new dataset
// assigns new handle to dataset
pDoc->MakeData();
pDataSet1 = pDoc->pContourData;
// get handles for line plot and scatter plot object
HGOBJ hPlot = pGraph->hPlot;
if (!hPlot)
return;
// Delete old contour plot
pGraph->WGDeleteObject(hPlot);
// delete old dataset objects now
if (pTemp1)
delete pTemp1;
pTemp1 = NULL;
if (pDoc->lpX1)
free( pDoc->lpX1);
pDoc->lpX1 = NULL;
// Add new contour plot
pGraph->WGPreAddGraphObject();
pGraph->AddContourGraph();
pGraph->WGPostAddGraphObject();
QCPageFormView::OnTimer(nIDEvent);
}
void CGraph::AddContourGraph()
{
realtype rContourValues[] = {-3.5, -2.1, -1.1, 0.0, 2.1, 3.1, 4.1, 5.1};
COLORREF rgbColors[] = {1, 11, 12, 13, 14, C_LIGHTGRAY, C_GREEN, C_RED, C_BLACK, C_BLACK};
int nLineStyle[] = {PS_SOLID, PS_SOLID,PS_SOLID,PS_SOLID,PS_SOLID,PS_SOLID,PS_SOLID,PS_SOLID};
int nLineWidth[] = {1,1,1,1,1,1,1,1};
int bContourLineFlags[] = {TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE};
int bContourLabelFlags[] = {TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE};
int i, granularity;
QCStaticData * pContourData; // data set handle
CContourDDoc * pDoc = pSDoc;
pContourData = (QCStaticData *) pDoc->pContourData;
for (i=0; i < 8; i++)
rgbColors[i] = WGGetRGBColor(rgbColors[i]);
granularity = 1;
WGSetTextParams (C_BLACK, FF_ROMAN, 10, TEXT_BOLD);
hPlot = WGContourPlot (
pContourData,
rContourValues,
rgbColors,
nLineStyle,
nLineWidth,
7,
granularity,
bContourLineFlags,
bContourLabelFlags,
POS_RIGHT,
POS_ABOVE,
1,
TRUE,
GT_CONTOURFILL);
}