//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "DefineQBal.h"
#include "String_doubleUnit.h"
#include "SelectProfilSect.h"
#include "ProcExt.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TDefineQBalForm *DefineQBalForm;
//---------------------------------------------------------------------------
__fastcall TDefineQBalForm::TDefineQBalForm(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TDefineQBalForm::FormShow(TObject *Sender)
{
   len_plane = SelectProfilSectForm->Data_select.Length[SelectProfilSectForm->n_plane];
   Edit_Len->Text = FloatToStr(len_plane);
   RadioGroup_constClick(Sender);

}
//---------------------------------------------------------------------------
void __fastcall TDefineQBalForm::BitBtn_CloseClick(TObject *Sender)
{
   Mx_bal = 0;
   Qy_bal = 0;

   Close();
}
//---------------------------------------------------------------------------
void __fastcall TDefineQBalForm::BitBtn_ApplyClick(TObject *Sender)
{

   int rc = String_double(Label_Q->Caption, Edit_qa->Text, &(q_bal));
   if (rc>0)
	 return;
   Mx_bal = Round(0.125*q_bal*len_plane*len_plane*1e-6, 2);
   Qy_bal = Round(0.5*q_bal*len_plane*1e-3, 2);

   Close();
}

void __fastcall TDefineQBalForm::RadioGroup_constClick(TObject *Sender)
{
  if (RadioGroup_const->ItemIndex==0) {
	Edit_qb->Enabled = false;
  }
  else {
	Edit_qb->Enabled = true;
  }

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

void __fastcall TDefineQBalForm::Edit_qaChange(TObject *Sender)
{
  if (RadioGroup_const->ItemIndex==0) {
	 Edit_qb->Text = Edit_qa->Text;
  }
}
//---------------------------------------------------------------------------

void __fastcall TDefineQBalForm::ComboBox_oporaChange(TObject *Sender)
{
  if (ComboBox_opora->ItemIndex==1)
	ComboBox_opora->ItemIndex=0;
}
//---------------------------------------------------------------------------

