LoginSignup
0
2

More than 5 years have passed since last update.

2016-03-31 c++ builder / teechart > Link > 多量のプロットの描画高速化 + 実装ミスの訂正(2019-04-11)

Last updated at Posted at 2016-03-31
動作環境
C++ Builder XE4

TeeChartで多量のプロットを短時間で描画したとき、描画が遅くなる症状に出くわした。
スレッド関連の実装も関係あるとは思うが検索してみたところ、以下を見つけた。

delphiコード

Chart.Series[0].XValues.Value := TChartValues(XValues);
Chart.Series[0].XValues.Count := high(XValues);
Chart.Series[0].XValues.Modified := true;

同様にYValusも入れる。

delphiのHigh()は
http://www.delphibasics.co.uk/RTL.asp?Name=High

C++の場合は TDoubleDynArray を使うようだ。
関連 http://www.teechart.net/support/viewtopic.php?f=3&t=15201

TDoubleDynArray xs, ys;
xs.Length = 2000;
ys.Length = 2000;

...
xs[idx] = 3.14;
ys[idx] = 2.71;
...

m_targetSeries->XValues->Value = xs;
m_targetSeries->XValues->Count = cnt;
m_targetSeries->XValues->Modified = true;
m_targetSeries->YValues->Value = ys;
m_targetSeries->YValues->Count = cnt;
m_targetSeries->YValues->Modified = true;

しかし、この方法では既存の折れ線の後ろにプロットを追加する場合、以下のような処理が先に必要になる。

// 既存のプロットからの読込み
for(int idx=0; idx < m_targetSeries->XValues->Count; idx++) {
    xs[cnt++] = m_targetSeries->XValues->Value[idx];
    ys[cnt++] = m_targetSeries->YValues->Value[idx];
}

実装のミス

(追記 2019/04/11)

上記の「// 既存のプロットからの読込み」の処理に実装ミスが見つかった。
下記のようにする必要がある。cntを余分にインクリメントしていた。

// 既存のプロットからの読込み
for(int idx=0; idx < m_targetSeries->XValues->Count; idx++) {
    xs[cnt] = m_targetSeries->XValues->Value[idx];
    ys[cnt] = m_targetSeries->YValues->Value[idx];
    cnt++;
}
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2