由于原生函数支持,wxWidgets 是否比 qt 更适合绘制波形? [英] Is wxWidgets better for drawing waveforms than qt because of native function support?

查看:30
本文介绍了由于原生函数支持,wxWidgets 是否比 qt 更适合绘制波形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道wxWidget是否比qt更快地满足我的特殊需求

I'm just wondering, whether wxWidget is for my special needs faster than qt

简单的事情.我想像 Audacity 一样快地绘制波形.我尝试了与 Audacity 完全相同的方法,但我只是想出了一种接近 Audacity 的性能,但仍然不如 Audacity 快.

Simple thing. I want to draw waveforms as fast as Audacity. I tried quite the same approach like in Audacity but I've come only up with a performance which comes near to Audacity, but still isn't as fast as Audacity.

我的想法是,对于具有令人难以置信的性能/反馈的位图绘制,Qt 不是最佳选择.来自 Audacity 文档:

My thought is, that Qt is suboptimal for bitmap drawing with incredible performance/feedback. From the Audacity documentation:

屏幕更新混合使用了直接绘制和间接绘制事件.更新图形显示的正常"方法是调用当某些事情使屏幕无效时,Refresh() 方法.后来,该系统调用 OnPaint(),应用程序覆盖它以(重新)绘制屏幕.在 wxWidgets 中,你也可以直接在屏幕上绘制而不需要调用 Refresh() 而无需等待 OnPaint() 被调用.

The screen update uses a mixture of direct drawing and indirect paint events. The "normal" way to update a graphical display is to call the Refresh() method when something invalidates the screen. Later, the system calls OnPaint(), which the application overrides to (re)draw the screen. In wxWidgets, you can also draw directly to the screen without calling Refresh() and without waiting for OnPaint() to be called.

因此,参考这个,可以像使用 Qt 一样使用 wxwidget 绘制更直接",如果是这样,那真的更快吗?(我还没有发现使用 Qt 将直接"绘制到帧缓冲区的任何可能性)

So refering to this, it's possible to draw "more direct" with wxwidget as I could with Qt and if so is that really faster? (I haven't found any posibility for drawing "direct" to the framebufferwith Qt)

更新:因为它被要求我提供我的绘制代码(使用 qwt 和自己的 QwtPlotIntervalCurve 实现.在这种状态下没有缓存/位图使用;随意提出优化建议;每个缩放阶段最多只能绘制 1024 个点).此代码是针对最小值/最大值和 RMS 值完成的.

UPDATE: Because it was asked for I give my draw code (using qwt with own implementation of QwtPlotIntervalCurve. In this state without caching/bitmap usage; Feel free to suggest optimizations; There will only be a maximum of 1024 points drawn every zoom stage). This code is done for the min / max values and for the RMS values.

void WaveformWidget::QwtPlotIntervalCurveFast::drawTube(QPainter * painter, const QwtScaleMap & xMap, const QwtScaleMap & yMap, const QRectF & canvasRect, int from, int to) const
{
  painter->save(); //Not best performance but for some people it suits.
  painter->setPen(this->pen()); //Feel free to use it.
  std::vector<QwtIntervalSample> draw = getToDrawData(xMap, yMap);
  double x, y1, y2;
  std::vector<QLine> lines(draw.size());
  for (int i = 0; i < draw.size(); i++) {
      x = xMap.transform(draw[i].value);
      y1 = yMap.transform(draw[i].interval.minValue());
      y2 = yMap.transform(draw[i].interval.maxValue());
      lines[i] = (QLine(x, y1, x, y2));
  }
  painter->drawLines(lines.data(), lines.size());
  painter->restore();
}

更新2:现在分析附件:)

UPDATE 2: Now profiling attachment :)

抱歉,它是德语.

更新 3:这就是东西的样子.这是一个没有任何噪音的正弦波.在绘制真实信号之前只需大约 1 或 2 个缩放阶段(如果可以,请尝试给我一个关于它看起来如何的反馈.那太好了,花了太多时间在如何快速绘制波形和伟大的").是的,Audacity 会阻止 rms 值大于最大值/最小值.稍后我会添加.

Update 3: That's how the stuff looks like. It's a sin wave without any noise. Simply about 1 or 2 zoom stages before the real signal would be drawn( if you can please try to give me a feedback on how it's looking like for you. That would be great, spent too much time on "how to draw waveforms fast and great"). And yes Audacity stops rms values from being greater than max/min values. I'll add that later.

不分离地绘制曲线会大大提高性能吗?

Would drawing the curves unseperated boost the performance that much?

更新:

在调整波形小部件的大小"期间,我将应用程序的处理器使用情况与大胆进行了比较.在调整小部件大小期间,Audacity 使用的处理器时间至少比我的应用程序少 10%.在这些操作中,我的计算机使用了 20%(我的 30%).

I compared the processor usage of my application to audacity during "resizing the waveform widget". Audacity does at least use 10 % less processor time than my application during resizing the widget. The total usage of audacity during such operations lies with my computer at 20 % (mine 30%).

推荐答案

很差,我只能针对 windows 系统回答这个问题.

Poorly I can only answer this question for windows systems.

我发现 wxWidgets 在这种情况下比 qt 快.

我认为造成这种情况的原因是绘画可以独立于绘画事件而应用,并且绘画是直接在屏幕上完成的.此外,如果需要双缓冲(例如本机位图),wxWidgets 可以使用操作系统特定的加速.

What I think causes this is that painting can be applied independently of a paint event and painting is done directly on the screen. Furthermore wxWidgets can use os specific acceleration if double buffering is wished (e.g. a native bitmap).

相比之下,Qt 使用双缓冲(据我所知)在 Windows 系统上无法禁用(但在 linux 系统上可以).

In contrast, Qt uses double buffering which (so far I know) cannot be disabled on Windows system (however on linux systems it can).

因为这个问题只针对Windows系统回答我不接受.

Because this question is only answered for Windows system I do not accept it.

附注:如果有人可以对Linux系统进行一些测试,请与我联系,我将提供代码.

PS: If someone could make some tests for Linux systems, please do and or contact me, I will provide the code.

这篇关于由于原生函数支持,wxWidgets 是否比 qt 更适合绘制波形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆