📄 surfacecontour.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include <math.h>
#pragma hdrstop
#include "surfacecontour.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "ChartfxLib_TLB"
#pragma link "OleCtrls"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
short i,j;
String s;
ICfxAxisDisp pAxis;
// Initialize data
ChartFX1->Axis->get_Item(AXIS_Y,&pAxis);
pAxis.ResetScale();
pAxis.Decimals = 0;
// Set smooth data
ChartFX1->OpenDataEx(COD_VALUES, 20, 20);
for (i = 0; i < 20; i++) {
if (i % 2 == 0) {
s = i;
ChartFX1->KeySer[i] = StringToOleStr(s); // X-Axis labels
}
for (j = 0; j < 20; j++)
ChartFX1->ValueEx[i][j] = (sin((i * 2 * 3.1416) / 19) * cos(((j + 5) * 2 * 3.1416) / 19)) * 100;
}
ChartFX1->CloseData(COD_VALUES);
// 3D Settings
ChartFX1->View3DDepth = 60;
ChartFX1->AngleX = 30;
ChartFX1->AngleY = 45;
// Constrains
ChartFX1->ShowTips = False;
ChartFX1->AllowDrag = False;
ChartFX1->SerLegBoxObj->set_BorderStyle(BBS_NONE);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
ICfxAxisDisp pAxis;
// Surface plot
ChartFX1->LeftGap = 30;
ChartFX1->RightGap = 10;
ChartFX1->TopGap = 10;
ChartFX1->BottomGap = 20;
ChartFX1->Gallery = SURFACE;
ChartFX1->SetContourLabels(20); // 20 is my "layer size"
ChartFX1->SerLegBoxObj->set_Docked(TGFP_BOTTOM);
ChartFX1->Axis->get_Item(AXIS_Y,&pAxis);
pAxis.Style |= AS_BREAKZERO;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
ICfxAxisDisp pAxis;
// Contour plot
ChartFX1->LeftGap = 0;
ChartFX1->RightGap = 20;
ChartFX1->TopGap = 0;
ChartFX1->BottomGap = 0;
ChartFX1->Gallery = CONTOUR;
ChartFX1->SetContourLabels(20); // 20 is my "layer size"
ChartFX1->SerLegBoxObj->set_Docked(TGFP_RIGHT);
ChartFX1->Axis->get_Item(AXIS_Y,&pAxis);
pAxis.Style &= ~AS_BREAKZERO;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -