Page 1 of 1

Help wanted overcoming delay in repainting contour graph

Posted: Thu Apr 17, 2025 1:27 pm
by 16491898
I am trying to create a contour graph that uses ISO axes (i.e. the same X and Y scales) AND has a number of circles drawn on top of it. Screenshot #2 (correct) below shows the graph I am trying to produce.
Screenshot 2 (correct).jpg
Screenshot 2 (correct).jpg (111.84 KiB) Viewed 2277 times
The problem is that, when the graph first appears, the axes are not scaled properly, as shown here:
Screenshot 1 (wrong).jpg
Screenshot 1 (wrong).jpg (127.84 KiB) Viewed 2277 times
I have put the code that adjusts the scales AND draws the circles is the chart's AfterDraw event handler:

Code: Select all

void __fastcall TGxGraphPaper::TeeChartAfterDraw(TObject *Sender)
{
	if(auto plot = dynamic_pointer_cast<BoundaryElementContourPlot, TeeGraph>(contour_graph)) {
		// adjust the axes
		plot->MakeIsoAxis();    // THIS CALL ADJUSTS THE AXES

		// draw the piles
		if(auto analysis = dynamic_pointer_cast<const Repute::BoundaryElementAnalysis>(data))
			plot->DrawPileGroup(*analysis.get());    // THIS CALL DRAWS THE CIRCLES
	}
}
The strange thing is the WRONG drawing displays the circles, so has clearly gone through the AfterDraw event.

It is only when I move the mouse over the drawing that the graphs flashes and then displays the CORRECT drawing, without going through AfterDraw a second time.

Can anyone please explain what is happening here? What am I missing?

Thanks in advance.

Andrew Bond

Re: Help wanted overcoming delay in repainting contour graph

Posted: Wed Apr 23, 2025 7:16 am
by yeray
Hello Andrew,

This probably happens because the MakeIsoAxis function changes the axes scales but doesn’t redraw the chart, so the changes only take effect the next time the chart is drawn.
To fix this, you likely just need to force a chart redraw by calling Draw() at the end of your FormCreate event or a similar initialization routine.

Re: Help wanted overcoming delay in repainting contour graph

Posted: Thu Apr 24, 2025 11:29 am
by 16491898
Thanks, Yeray, that worked