C++ Builder 10.2 Tokyo > FastReport > TfrxLineViewerで線を引く > performance:20万本の描画は不可能


動作環境
RAD Studio 10.2 Tokyo Update 3
Fast Report VCL 5

概要

  • FastReportを使って動的に線を描画する
    • デザインでなく、コードで追加
  • 20万本の線の描画の事前調査

参考

4本の赤い線を引く実装例 (ただし、ロシア語)
https://www.fastreport.ru/ru/forum/index.php?showtopic=8995

Delphiコードを参考に、C++ Builderでの実装を検討した。

実装

Unit1.h
//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include "frxClass.hpp"
#include "frxExportPDF.hpp"
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:    // IDE で管理されるコンポーネント
    TfrxPDFExport *frxPDFExport1;
    TfrxReport *frxReport1;
    TButton *Button1;
    void __fastcall frxReport1BeforePrint(TfrxReportComponent *Sender);
    void __fastcall Button1Click(TObject *Sender);
private:    // ユーザー宣言
public:     // ユーザー宣言
    __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
Unit1.cpp
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "frxClass"
#pragma link "frxExportPDF"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::frxReport1BeforePrint(TfrxReportComponent *Sender)
{
    static TfrxLineView *lines[200];

    for(int idx=0; idx < 200; idx++) {
        lines[idx] = new TfrxLineView(Sender);
        lines[idx]->SetBounds(10, 10 + idx * 3, 30, 2);
        lines[idx]->Printable = true;
        lines[idx]->Frame->Color = clRed;
        lines[idx]->Frame->Width = 2;
    }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    frxPDFExport1->FileName = L"test.pdf";
    frxPDFExport1->ShowDialog = false;
    frxReport1->PrepareReport(true);
    frxReport1->Export(frxPDFExport1);
}
//---------------------------------------------------------------------------

実行例

生成されたPDFファイルのキャプチャ。
緑色の線はもともとFastReportのデザイナで自分で追加しておいたもの。
赤の線が動的に追加した線。
(200本を下方向にずらしながら追加)

Performance

200本の線を描画したが、200本を超すと処理が固まるようになった。
FastReportにてTfrxLineView を動的に追加する本数としては200本未満になりそう。

20万本の描画は無理と分かった。