Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Windows
 Charting and Real-Time Graphics Tools for Windows
 Contour plot
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Frank

5 Posts

Posted - 18 Aug 2006 :  18:40:49  Show Profile  Reply with Quote
Seem to have a little hassle trying to get the contour plot to redraw after the data has changed. The reconnect data seems to have worked, because the data dialog displays the new data. However, the graph displayed it the old one. I have a variety of hacks, and none seems to work. Do you have any suggestions for me?

Regards

Frank

Frank

quinncurtis

1164 Posts

Posted - 18 Aug 2006 :  20:39:52  Show Profile  Reply with Quote
Because of extensive preprocessing that takes place
when a contour plot is created, normally the contour
plot is not replotted in response to the WGRedrawObject
function. Doing so would make it very slow to resize a
window that had a contour plot in it.

If you modify the data in a contour plot and want it
to redraw, call the WGDeletePlotBitmap function before
you cann WGRedrawObject or WGRedrawGraph.

	WGDeletePlotBitmap(pGrDesc,hPlotFill);
        WGRedrawGraph(pGrDesc,TRUE);
Go to Top of Page

Frank

5 Posts

Posted - 19 Aug 2006 :  02:23:45  Show Profile  Reply with Quote
Thanks for response. However WGDeletePlotBitmap return false, even right at the beginning of the OnUpdate function. Code snippet is as follows:

if (!pGraph->WGIsGraphValid ()) return;
WGStart();
HGOBJ hTPlot;
hTPlot = pGraph->GetTemp2DHandle();
a = pGraph->WGDeletePlotBitmap(hTPlot);

Any further help?

Regards

Frank


Go to Top of Page

Frank

5 Posts

Posted - 19 Aug 2006 :  02:40:47  Show Profile  Reply with Quote
Of course, its is my OnUpdateGraph function that I meant below, not an MFC function.

Another thing, in your ContourD example, your have a line to produce the text "TEST" on screen. However, it does not display because it is below the bitmap for the contour plot. There seems t be an issue about layering in these plots.

I tried deleting the Plot Bitmap directly after creating it in buildgraph and it failed as well. I checked the PGRAPH_DEF pointer tot he graph object using GetGraphDesc and step through the MFC wrapper for QC and there was not a issue on that side.

This is an major hassle for me right now, as the user wants to see the data as she changes it.

[quote]Originally posted by Frank

Thanks for response. However WGDeletePlotBitmap return false, even right at the beginning of the OnUpdate function. Code snippet is as follows:

if (!pGraph->WGIsGraphValid ()) return;
WGStart();
HGOBJ hTPlot;
hTPlot = pGraph->GetTemp2DHandle();
a = pGraph->WGDeletePlotBitmap(hTPlot);

Any further help?

Regards

Frank


Go to Top of Page

quinncurtis

1164 Posts

Posted - 19 Aug 2006 :  18:23:32  Show Profile  Reply with Quote
We tried to create a simple example that updated a filled contour plot but were not able, probably as a result of the same problem you are having. We will have to look into it further next week.
Go to Top of Page

quinncurtis

1164 Posts

Posted - 21 Aug 2006 :  11:06:31  Show Profile  Reply with Quote
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);
}

Go to Top of Page

Frank

5 Posts

Posted - 21 Aug 2006 :  12:15:08  Show Profile  Reply with Quote
Thaks I will give this a try and get back to you. Appreciate your help.
Frank
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07