ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Windrose - general
Posted by Ian on Jun-01-2021 18:59
Hi Peter, I have a few questions..

1) My windrose comprises 16 sectors labeled "N"..."S". Are the labels part of the PlotArea or drawn outside?
2) I allow the user to drag the containing window in either direction and recalculate the centre and radius of the windrose. Across the top and bottom of the display area is a text area which the labels sometimes impinge. I am trying to work an algorithm that will take into consideration the position of the labels. Can you please advise.
3) When I drag the edges of the container, the windrose labels and grid lines thicken or the grid lines can look as if there are 2 crossed and then eventually you hit a size where it settles down.
4) Can you advise on the best position for the viewer->invalidate(). I cannot seem to get the chart to refresh when I move the container.

Many thanks for your advice

  Re: Windrose - general
Posted by Peter Kwan on Jun-02-2021 01:11
Hi Ian,

Are you using ChartDirector 7.0, with the CChartViewer comes from ChartDirector 7.0, or are you using an earlier version?

By default, an MFC control draw itself by (a) drawing a background rectangle with the control background color to clear everything under the control, then (b) draw the control.

In earlier versions of ChartDirector, it disables (a) so the background is not cleared. It works if the chart is painted once and not moving. If it is painted a second time, the first chart will become the background of the second chart, that is, the two charts will overlap. Because modern graphics uses antialias, the effect is the color becomes darker and lines become thinker. (Imagine a semi-transparent grey color. If it is painted multiple times over the same spot, the spot will become darker and darker.) Using invalidate will not solve the problem. The key reason is because step (a) is omitted, that is, it does not erase the background first.

In ChartDirector 7.0, CChartViewer will ask the parent Window to paint the CChartViewer's background with its own background. So if the background image is really the parent Windows background, it will work even if the background image can change. Now if you just moves the control, MFC will not even bother to notify the control. It just copies the pixels within the control's rectangle, so it will move even its own background inside the control. The invalidate can force MFC to redraw the everything instead of copying the pixels.

I have attached a modified MFC helloworld sample code in ChartDirector 7.0. The chart has been modified with a transparent polar chart, and the window has a background image. For simplicity, I put two buttons to move the control left and right. You can try it yourself. You can try to remove the invalidate line in the code to see what is the difference. To try the code, please replace the MFC helloworld folder in the sample code with the folder in the attached zip.

For the plot area region, the plot area region only applies to XYChart objects. For other charts, the entire chart is considered as the plot area. If you want to determine if the mouse is inside the polar grid, you can compute the distance between the mouse cursor and the center, and check if this is less than or equal to the radius.

Peter Kwan

80.42 Kb