Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабораторные работы №4 и №5 / gera / Unit1
.cpp//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
#include "translator.h"
#include "methods.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
myFunction *Function1;
int _vc;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
double Method1(myFunction *F,TVector SP,TVector D, char *names)
{
double a=0,b=0;
Swann((*F),a,b,SP,D,names,1);
double res=a;
return res;
};
void __fastcall TForm1::Button1Click(TObject *Sender)
{
double t;
if(!_vc) ShowMessage("Error");
char *StartDotCoordsText=strdup(Edit2->Text.c_str());
char *TextReal=NULL;
int i=0,initErrors=0;
double mas[26],*ms;
AnsiString str1;
double a=0, b=0;
TVector SP, PP, vctr;
//reinit / init
//Converting StartPoing
mas[0]=StrToFloat(strtok(StartDotCoordsText,","));
for(i=1;i<_vc;i++)
{
TextReal=strtok(NULL,",");
if(TextReal)
mas[i]=StrToFloat(TextReal);
else
{
MessageDlg("Insuficient quatity of args\nPlace: StartPoint",mtError,TMsgDlgButtons() << mbOK,0);
if(StartDotCoordsText)
free(StartDotCoordsText);
initErrors=1;
return ;
};
};
if(StartDotCoordsText)
free(StartDotCoordsText);
ms=new double[vc];
for(i=0;i<vc;i++)
ms[i]=mas[i];
TVector StartPoint(ms,_vc);
SP=StartPoint;
//ConvertingDirection
TextReal=NULL;
char *DirectionText=strdup(Edit3->Text.c_str());
mas[0]=StrToFloat(strtok(DirectionText,","));
for(i=1;i<_vc;i++)
{
TextReal=strtok(NULL,",");
if(TextReal)
mas[i]=StrToFloat(TextReal);
else
{
MessageDlg("Insuficient quatity of args\nPlace: Direction",mtError,TMsgDlgButtons() << mbOK,0);
initErrors=1;
};
};
if(DirectionText)
free(DirectionText);
TVector Direction(mas,_vc);
PP=Direction;
if(!initErrors)
{
if(RadioButton1->Checked)
{
//method 1
//Подразумеваю, что в метод будет передан переменная класса
//функции, два класса векторов - насальная точка и направление
//возвращает строчку с отчетом, которая затем присваивается Memo.Lines
//double p=Method1(Function1,StartPoint,Direction,vars);
//Memo1->Lines->Add(FloatToStr(p));
str1=Swann(*Function1,a,b,StartPoint,Direction,vars,1);
Memo1->Lines->Add(str1);
//str1=TPS(*Function1,a,b,SP,PP,vars);
//Memo1->Lines->Add(str1);
}
else if(RadioButton2->Checked)
{
//method 1
//Подразумеваю, что в метод будет передан переменная класса
//функции, два класса векторов - насальная точка и направление
//возвращает строчку с отчетом, которая затем присваивается Memo.Lines
//double p=Method1(Function1,StartPoint,Direction,vars);
//Memo1->Lines->Add(FloatToStr(p));
str1=Swann(*Function1,a,b,StartPoint,Direction,vars,2);
Memo1->Lines->Add(str1);
//str1=TPS(*Function1,a,b,SP,PP,vars);
//Memo1->Lines->Add(str1);
}
else if(RadioButton3->Checked)
{
Memo1->Lines->Add(MPK(*Function1,StartPoint,vars));
}
}else
ShowMessage("Errors while init");
delete mas;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormShow(TObject *Sender)
{
AboutBox->Hide();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
if(Function1)
{
delete Function1;
Function1=NULL;
}
Function1=new myFunction(StartTranslation(Edit1->Text.c_str()));
Label1->Caption=Edit1->Text;
_vc=vc;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Exit1Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
delete Function1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton1Click(TObject *Sender)
{
Button2->Click();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton2Click(TObject *Sender)
{
Button2->Click();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton3Click(TObject *Sender)
{
Button2->Click();
}
//---------------------------------------------------------------------------
Соседние файлы в папке gera