📄 mainfrm.cpp
字号:
////////////////////////////////////////////////////////////////////////////////
#include <vcl\vcl.h>
#pragma hdrstop
#include "MainFrm.h"
////////////////////////////////////////////////////////////////////////////////
#pragma link "cgauges"
#pragma resource "*.dfm"
TMainForm *MainForm;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
__fastcall TMainForm::TMainForm(TComponent* Owner)
: TForm(Owner)
{
}
////////////////////////////////////////////////////////////////////////////////
void __fastcall TMainForm::FormCreate(TObject *Sender)
{
FC = new TMigrationFC(/*fragment*/);
// initial types
AggregationProductClick(Sender);
CorrelationTruncateClick(Sender);
AlphaCutStrongClick(Sender);
CompositionBoundedSumClick(Sender);
DefuzzificationNearEdgeClick(Sender);
Update();
}
////////////////////////////////////////////////////////////////////////////////
void __fastcall TMainForm::FormDestroy(TObject *Sender)
{
if (FC != NULL) delete FC; FC = NULL;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
void __fastcall TMainForm::Update(void)
{
// measured inputs
int index = 0;
input11 = Input11TrackBar->Position;
input12 = Input12TrackBar->Position;
input21 = Input21TrackBar->Position;
input22 = Input22TrackBar->Position;
output1 = FC->RunC1(index, input11, input12, AggregationMethod, CorrelationMethod, AlphaCutType, CompositionMethod, DefuzzificationMethod);
output2 = FC->RunC2(index, input21, input22, AggregationMethod, CorrelationMethod, AlphaCutType, CompositionMethod, DefuzzificationMethod);
output = FC->RunC3(index, output1, output2, AggregationMethod, CorrelationMethod, AlphaCutType, CompositionMethod, DefuzzificationMethod);
PaintBox1->Refresh();
PaintBox2->Refresh();
PaintBox ->Refresh();
}
////////////////////////////////////////////////////////////////////////////////
void __fastcall TMainForm::FormKeyPress(TObject *Sender, char &Key)
{
if(Key == VK_ESCAPE)
{
Close();
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//---------------------------------------------------------------------------
void __fastcall TMainForm::PaintBox1Paint(TObject *Sender)
{
PaintBox1->Canvas->Pen->Color = clGreen;
if (FC->C1->input_variables[0]->fuzzysets[0] != NULL) FC->C1->input_variables[0]->fuzzysets[0]->Draw(PaintBox1->Canvas);
if (FC->C1->input_variables[0]->fuzzysets[1] != NULL) FC->C1->input_variables[0]->fuzzysets[1]->Draw(PaintBox1->Canvas);
if (FC->C1->input_variables[0]->fuzzysets[2] != NULL) FC->C1->input_variables[0]->fuzzysets[2]->Draw(PaintBox1->Canvas);
PaintBox1->Canvas->Pen->Color = clAqua;
if (FC->C1->input_variables[1]->fuzzysets[0] != NULL) FC->C1->input_variables[1]->fuzzysets[0]->Draw(PaintBox1->Canvas);
if (FC->C1->input_variables[1]->fuzzysets[1] != NULL) FC->C1->input_variables[1]->fuzzysets[1]->Draw(PaintBox1->Canvas);
if (FC->C1->input_variables[1]->fuzzysets[2] != NULL) FC->C1->input_variables[1]->fuzzysets[2]->Draw(PaintBox1->Canvas);
PaintBox1->Canvas->Pen->Color = clInfoBk;
if (FC->C1->output_variable->fuzzysets[0] != NULL) FC->C1->output_variable->fuzzysets[0]->Draw(PaintBox1->Canvas);
if (FC->C1->output_variable->fuzzysets[1] != NULL) FC->C1->output_variable->fuzzysets[1]->Draw(PaintBox1->Canvas);
if (FC->C1->output_variable->fuzzysets[2] != NULL) FC->C1->output_variable->fuzzysets[2]->Draw(PaintBox1->Canvas);
if (FC->C1->output_variable->fuzzysets[3] != NULL) FC->C1->output_variable->fuzzysets[3]->Draw(PaintBox1->Canvas);
if (FC->C1->output_variable->fuzzysets[4] != NULL) FC->C1->output_variable->fuzzysets[4]->Draw(PaintBox1->Canvas);
if (FC->remote_attractionsets[0] != NULL)
{
PaintBox1->Canvas->Pen->Color = clBlue;
FC->remote_attractionsets[0]->Draw(PaintBox1->Canvas);
PaintBox1->Canvas->Pen->Color = clRed;
double scalar = ((FC->remote_attractions[0] - FC->remote_attractionsets[0]->get_variable()->begin)/(FC->remote_attractionsets[0]->get_variable()->end - FC->remote_attractionsets[0]->get_variable()->begin))*DOMAIN_WIDTH;
PaintBox1->Canvas->MoveTo(2 * scalar, 100 * 0.0);
PaintBox1->Canvas->LineTo(2 * scalar, 100 * 1.0);
PaintBox1->Canvas->Refresh();
Output1CGauge->Progress = ((int)FC->remote_attractions[0]);
}
}
//---------------------------------------------------------------------------//---------------------------------------------------------------------------////////////////////////////////////////////////////////////////////////////////
void __fastcall TMainForm::Input11TrackBarChange(TObject *Sender)
{
Input11ValueLabel->Caption = IntToStr(Input11TrackBar->Position);
Update();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::Input12TrackBarChange(TObject *Sender)
{
Input12ValueLabel->Caption = IntToStr(Input12TrackBar->Position);
Update();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TMainForm::AboutClick(TObject *Sender)
{
AboutBox->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::AggregationZadehClick(TObject *Sender)
{
AggregationZadeh->Checked = true;
AggregationMean->Checked = false;
AggregationMeanSquare->Checked = false;
AggregationMeanRoot->Checked = false;
AggregationProduct->Checked = false;
AggregationBoundedSum->Checked = false;
AggregationMethod = ZADEH;
AggregationLabel->Caption = " Zadeh";
Update();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::AggregationMeanClick(TObject *Sender)
{
AggregationZadeh->Checked = false;
AggregationMean->Checked = true;
AggregationMeanSquare->Checked = false;
AggregationMeanRoot->Checked = false;
AggregationProduct->Checked = false;
AggregationBoundedSum->Checked = false;
AggregationMethod = MEAN;
AggregationLabel->Caption = " Mean";
Update();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::AggregationMeanSquareClick(TObject *Sender)
{
AggregationZadeh->Checked = false;
AggregationMean->Checked = false;
AggregationMeanSquare->Checked = true;
AggregationMeanRoot->Checked = false;
AggregationProduct->Checked = false;
AggregationBoundedSum->Checked = false;
AggregationMethod = MEANSQUARE;
AggregationLabel->Caption = " Mean^2";
Update();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::AggregationMeanRootClick(TObject *Sender)
{
AggregationZadeh->Checked = false;
AggregationMean->Checked = false;
AggregationMeanSquare->Checked = false;
AggregationMeanRoot->Checked = true;
AggregationProduct->Checked = false;
AggregationBoundedSum->Checked = false;
AggregationMethod = MEANROOT;
AggregationLabel->Caption = " Mean^.5";
Update();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::AggregationProductClick(TObject *Sender)
{
AggregationZadeh->Checked = false;
AggregationMean->Checked = false;
AggregationMeanSquare->Checked = false;
AggregationMeanRoot->Checked = false;
AggregationProduct->Checked = true;
AggregationBoundedSum->Checked = false;
AggregationMethod = PRODUCT;
AggregationLabel->Caption = " Product";
Update();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::AggregationBoundedSumClick(TObject *Sender)
{
AggregationZadeh->Checked = false;
AggregationMean->Checked = false;
AggregationMeanSquare->Checked = false;
AggregationMeanRoot->Checked = false;
AggregationProduct->Checked = false;
AggregationBoundedSum->Checked = true;
AggregationMethod = BOUNDEDSUM;
AggregationLabel->Caption = "BoundSum";
Update();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::CorrelationTruncateClick(TObject *Sender)
{
CorrelationTruncate->Checked = true;
CorrelationScale->Checked = false;
CorrelationMethod = TRUNCATE;
CorrelationLabel->Caption = "Truncate";
Update();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::CorrelationScaleClick(TObject *Sender)
{
CorrelationTruncate->Checked = false;
CorrelationScale->Checked = true;
CorrelationMethod = SCALE;
CorrelationLabel->Caption = " Scale";
Update();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::AlphaCutStrongClick(TObject *Sender)
{
AlphaCutStrong->Checked = true;
AlphaCutWeak->Checked = false;
AlphaCutType = STRONG;
AlphaCutLabel->Caption = "Strong";
Update();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::AlphaCutWeakClick(TObject *Sender)
{
AlphaCutStrong->Checked = false;
AlphaCutWeak->Checked = true;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -