简体   繁体   English

绘制点,然后将其删除

[英]Plotting points and then removing them

I have a set of points plotted. 我有一套要点。 After I scroll the trackbar I want them to disappear and a new set of points to appear. 滚动轨迹栏后,我希望它们消失并显示一组新的点。 Now the problem is the I cannot add the code for adding the points in the Paint method itself because it involves a lot of calculations and so is not efficient. 现在的问题是我无法在Paint方法本身中添加用于添加点的代码,因为它涉及大量计算,因此效率不高。 I tried using Invalidate() but in that case my points appear for a fraction of a second then disappear. 我尝试使用Invalidate(),但在这种情况下,我的积分出现了不到一秒钟,然后消失了。 I want them to be displayed till I click on the button or move the trackbar. 我希望它们一直显示到我单击按钮或移动轨迹栏为止。

How to go about doing it. 如何去做。

Thanks. 谢谢。

In your function that calculates the points, store the points into a list. 在计算点的函数中,将点存储到列表中。 In the paint function, draw according to the list. 在绘画功能中,根据列表进行绘制。 When required to change the points, simply clear the list of points and store new ones. 需要更改点时,只需清除点列表并存储新点即可。 Remember to Invalidate() 记住要Invalidate()

This way, each time Paint is called, the points are drawn. 这样,每次调用Paint时,都会绘制点。 you can still separately update your list in some other functions. 您仍然可以通过其他一些功能单独更新列表。

When you mention the points appearing then disappearing, it seems that you drew the points outside the paint function. 当您提到这些点出现然后消失时,似乎是在绘制功能之外绘制了这些点。 Is that true? 真的吗? When something happens paint draws over your drawing. 当发生某种情况时,油漆会覆盖您的图形。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM