⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 copy of ftestdisplay.cpp

📁 C++ Math Lib. C++ Builder must use.
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "fTestDisplay.h"
#include "dynarrays.h"
#include "dynarrutils.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
  pPlotBox2D = new PlotBox2D(this);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
  delete pPlotBox2D;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  pPlotBox2D->Parent = PanelBox;
  pPlotBox2D->NYTicks = 5;
  pPlotBox2D->NXTicks = 5;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  pPlotBox2D->SetLimits(-3.0,3.0,0.0,10.0);
  pPlotBox2D->PlotFrame();
  pPlotBox2D->OnPaint = PlotBox2DPaint;
  pPlotBox2D->SetPenColor(clRed);
  PlotBox2DPaint(this);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::PlotBox2DPaint(TObject *Sender)
{
  FArr1D x(100);
  FArr1D y(100);
  FArr1D z(100);
  double x1, x2, y1, y2, xx, dx;
  xx = -3.0;
  dx = 0.06;
  for (int i = 1; i <= 100; i++)
  {
    x(i) = xx; xx += dx;
    y(i) = exp(-xx*xx);
    z(i) = xx*y(i);
  };

  switch (RadioGroup1->ItemIndex)
  {
    case 0:
    {
    minmax(x, x1, x2, true);
    minmax(y, y1, y2, true);
    minmax(z, y1, y2, false);
    pPlotBox2D->SetLimits(x1,x2,y1,y2);
    pPlotBox2D->PlotFrame();
    pPlotBox2D->PlotArrays(x,y,clRed);
    pPlotBox2D->PlotArrays(x,z,clBlue);
    };
    break;
    case 1:
    {
    x1 = y.L1();
    x2 = y.H1();
    minmax(y, y1, y2, true);
    minmax(z, y1, y2, false);
    pPlotBox2D->SetLimits(x1,x2,y1,y2);
    pPlotBox2D->PlotFrame();
    pPlotBox2D->PlotArray(y,clRed);
    pPlotBox2D->PlotArray(z,clBlue);
    };
    break;
    default:;
  }; 

}
//---------------------------------------------------------------------------

void __fastcall TForm1::RadioGroup1Click(TObject *Sender)
{
  Button1->Click();      
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -