• 8858阅读
  • 4回复

[提问]qwt replot以及曲线类相关的问题 [复制链接]

上一主题 下一主题
离线dwx1011
 

只看楼主 倒序阅读 楼主  发表于: 2015-08-26
使用Qwt做一些图形的绘制。遇到两个问题
问题一:因为在绘制曲线中,曲线的坐标是不停的发生变化,所以就需要不停的重绘该条曲线(setSample),问题是,在一个plot中可能会有上百条曲线,如果一旦使用plot->replot的时候,整个界面会非常卡顿,造成效率及其底下,能否只更新这一条曲线,而不影响其他曲线?

问题二:在一段曲线中,可能每个关键节点的颜色都不同,比如说:0,0 是red颜色,0,20就是绿色。该如何实现?

以上
在线等,非常感激。
离线fyzhuhui

只看该作者 1楼 发表于: 2015-08-27
帮顶
离线kimtaikee

只看该作者 2楼 发表于: 2015-08-27
好问题。
1. 我试着只放了几个曲线进去就已经不能分清哪个是哪个了,更何况几十上百个曲线,所以你还是想想把它们的数量减少些。
2. Qwt不支持曲线的分段着色,因为上色之后一气呵成绘制出曲线的,代码如下, 当然我做了不少修改.
  1. void QwtPlotCurve::drawSeries( QPainter *painter,
  2.     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  3.     const QRectF &canvasRect, int from, int to ) const
  4. {
  5.     const size_t numSamples = dataSize();
  6.     if ( !painter || numSamples <= 0 )
  7.         return;
  8.     if ( to < 0 )
  9.         to = numSamples - 1;
  10.     if ( qwtVerifyRange( numSamples, from, to ) > 0 )
  11.     {
  12.         painter->save();
  13.         d_data->pen.setWidth(plot()->lineWidth());
  14.         painter->setPen( d_data->pen );
  15.         painter->setOpacity(plot()->lineOpacity());
  16.         /*
  17.           Qt 4.0.0 is slow when drawing lines, but it's even
  18.           slower when the painter has a brush. So we don't
  19.           set the brush before we really need it.
  20.          */
  21.         drawCurve( painter, d_data->style, xMap, yMap, canvasRect, from, to );
  22.         painter->restore();
  23.         if ( d_data->symbol &&
  24.             ( d_data->symbol->style() != QwtSymbol::NoSymbol ) )
  25.         {
  26.             painter->save();
  27.             drawSymbols( painter, *d_data->symbol,
  28.                 xMap, yMap, canvasRect, from, to );
  29.             painter->restore();
  30.         }
  31.         drawLabels( painter, *d_data->symbol,
  32.                    xMap, yMap, canvasRect, from, to );
  33.     }
  34. }

离线tianwaimmm

只看该作者 3楼 发表于: 2016-03-28
请问如何把横纵坐标的刻度线修改颜色呢?
离线eric_liu

只看该作者 4楼 发表于: 2018-02-02
楼主,我用的qcustomplot  实现了你提及的第二点,我这个曲线是动态的 ,绘制刷新率不是很好,比较头疼(闪  有点晃眼)不知道怎么解决

快速回复
限100 字节
 
上一个 下一个