C++ Builder XE4 > TeeChart > 多量のプロットの描画高速化 > 実行可能コード (2019-04-11版)
11872 ワード
動作環境
C++ Builder XE4
2016年3月31日の記事 > 分かりにくい
上記を参考に実装を進めようとしたが、分かりにくい。
さらに、実装ミスも見つかった。
もう、ほんと、ねぇ。
実行可能コード (2019-04-11版)
Unit1.h
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.ExtCtrls.hpp>
#include <VCLTee.Chart.hpp>
#include <VCLTee.Series.hpp>
#include <VCLTee.TeEngine.hpp>
#include <VCLTee.TeeProcs.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE で管理されるコンポーネント
TChart *Chart1;
TFastLineSeries *Series1;
TButton *Button1;
void __fastcall Button1Click(TObject *Sender);
private: // ユーザー宣言
public: // ユーザー宣言
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
Unit1.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <DateUtils.hpp>
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Chart1->Series[0]->XValues->DateTime = true;
Chart1->BottomAxis->DateTimeFormat = L"nn:ss";
TDateTime dt;
dt = Now();
int cnt = 0;
TDoubleDynArray xs, ys;
// 1. 既存データの読込み
xs.Length += Series1->XValues->Count;
ys.Length += Series1->XValues->Count;
for(int idx=0; idx < Series1->XValues->Count; idx++) {
xs[cnt] = Series1->XValues->Value[idx];
ys[cnt] = Series1->YValues->Value[idx];
cnt++;
}
// 2. 追加
const int numData = 10; // 追加データの個数
xs.Length += numData;
ys.Length += numData;
double yval;
for (int idx=0; idx < numData; idx++) {
yval = (1+ idx) % 2;
xs[cnt] = dt;
ys[cnt] = yval;
cnt++;
//
dt = IncMilliSecond(dt, 100);
}
Series1->XValues->Value = xs;
Series1->XValues->Count = cnt;
Series1->XValues->Modified = true;
Series1->YValues->Value = ys;
Series1->YValues->Count = cnt;
Series1->YValues->Modified = true;
Series1->Repaint(); // 描画の更新に必要
}
//---------------------------------------------------------------------------
実行例
- ボタンを数秒おきに押下した結果が以下
備考 > 資料として
- 動くことを確認したコードを載せること
- 閲覧者に分かりやすい書き方にすること
- 「40秒で支度しな」に答えられるように
Author And Source
この問題について(C++ Builder XE4 > TeeChart > 多量のプロットの描画高速化 > 実行可能コード (2019-04-11版)), 我々は、より多くの情報をここで見つけました https://qiita.com/7of9/items/4959921dd7f1057134ee著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .