void __fastcall TStmForm::ZoomInBtnClick(TObject *Sender)
{
r_res_x-=1000;
if (r_res_x<=0)
r_res_x=500;
SBar->Panels->Items[2]->Text="Resolution : "+IntToStr(r_res_x)+"ns";
DrawMnuClick(NULL);
}
//---------------------------------------------------------------------------
void __fastcall TStmForm::ZoomOutBtnClick(TObject *Sender)
{
if (r_res_x==500)
r_res_x+=500;
else
r_res_x+=1000;
SBar->Panels->Items[2]->Text="Resolution : "+IntToStr(r_res_x)+"ns";
DrawMnuClick(NULL);
}
//---------------------------------------------------------------------------
void __fastcall TStmForm::BackBtnClick(TObject *Sender)
{
offset-=r_res_x/10;
if (offset<0)
offset=0;
DrawMnuClick(NULL);
}
//---------------------------------------------------------------------------
void __fastcall TStmForm::StraightBtnClick(TObject *Sender)
{
offset+=r_res_x/10;
DrawMnuClick(NULL);
}
//---------------------------------------------------------------------------
void __fastcall TStmForm::FormMouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
CUR_X=X;
if (X<Width-OTSTUP)
{
char *val = new char [100];
int s_res_x=StmForm->Width,glob_y=-35,i;
double koef_x=(double)s_res_x/(double)r_res_x;
double _x=offset+X/koef_x;
int __x=_x;
Canvas->Font->Color=clWhite;
Canvas->Font->Size=10;
StmForm->Canvas->TextOut(Width-80,Height-90,IntToStr(__x)+" ns ");
for(i=sig_offset;i<num_signals;i++)
{
glob_y+=Y_STEP;
if (Y<glob_y+RAZBROS&&Y>glob_y-RAZBROS)
{
int global_y=-35;
int k;
for (int j=sig_offset;j<num_signals;j++)
{
global_y+=Y_STEP;
val=signals[j].GetName();
char *c=val;
for(k=0;val[k]&&val[k]!='.';k++,c++);c++;
val[k]=0;
if (i==j)
{
cur_sig=i;
Canvas->Font->Color=clLime ;
}
else
Canvas->Font->Color=clLtGray;
StmForm->Canvas->TextOut(Width-98,global_y,val);
if (i==j)
Canvas->Font->Color=clYellow;
else
Canvas->Font->Color=clWhite;
StmForm->Canvas->TextOut(Width-98,global_y+20,c);
}
}
}
delete val;
}
}
//---------------------------------------------------------------------------
void __fastcall TStmForm::NewStimMnuClick(TObject *Sender)
{
NewStimForm->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TStmForm::AboutMnuClick(TObject *Sender)
{
AboutForm->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TStmForm::DownBtnClick(TObject *Sender)
{
if (sig_offset<num_signals-1)
sig_offset+=1;
DrawMnuClick(NULL);
}
//---------------------------------------------------------------------------
void __fastcall TStmForm::UpBtnClick(TObject *Sender)
{
sig_offset-=1;
if (sig_offset==-1)
{
sig_offset=0;
}
DrawMnuClick(NULL);
}
//---------------------------------------------------------------------------
void __fastcall TStmForm::DelSigPMnuClick(TObject *Sender)
{
for (int i=cur_sig;i<num_signals;i++)
signals[i]=signals[i+1];
num_signals-=1;
DrawMnuClick(NULL);
}
//---------------------------------------------------------------------------
void __fastcall TStmForm::FormMouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
int s_res_x=StmForm->Width;
double koef_x=(double)s_res_x/(double)r_res_x;
double _x=offset+X/koef_x;
int __x=_x;
if (Button==mbRight)
{
PMnu->Popup(Left+X,Top+Y);
}
if (cur_sig<0)
return;
if (Button==mbLeft)
{
int dim=signals[cur_sig].GetDimension();
int index;
if((dim==2&&ctrl_down)||(dim==1&&ctrl_down))
{
index=signals[cur_sig].FindNearest(__x);
signals[cur_sig].delFF(index);
DrawMnuClick(NULL);
}
if(dim==2&&!ctrl_down)
{
signals[cur_sig].InsertFF(__x,"0");
DrawMnuClick(NULL);
}
if(dim==1&&!ctrl_down)
{
char *v=new char[5];
v=signals[cur_sig].GetValAtTime(__x);
if (v[0]=='0'||v[0]=='L'||v[0]=='Z')
signals[cur_sig].InsertFF(__x,"1");
if (v[0]=='1'||v[0]=='H')
signals[cur_sig].InsertFF(__x,"0");
delete v;
DrawMnuClick(NULL);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TStmForm::FormKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if (Key==VK_CONTROL)
{
ctrl_down=1;
SBar->Panels->Items[0]->Text="Mode : Deleting";
}
}
//---------------------------------------------------------------------------
void __fastcall TStmForm::FormKeyUp(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if(Key==VK_CONTROL)
{
ctrl_down=0;
SBar->Panels->Items[0]->Text="Mode : Editing ";
}
}
//---------------------------------------------------------------------------
void __fastcall TStmForm::FormActivate(TObject *Sender)
{
SBar->Panels->Items[0]->Text="Mode : Editing ";
SBar->Panels->Items[1]->Text="Filename : no file opened";
SBar->Panels->Items[2]->Text="Resolution : "+IntToStr(r_res_x)+"ns";
NewBasicForm->ValCB->ItemIndex=0;
NewClockForm->ValCB1->ItemIndex=0;
NewClockForm->ValCB2->ItemIndex=0;
}
//---------------------------------------------------------------------------
void __fastcall TStmForm::SaveAsMnuClick(TObject *Sender)
{
FILE *f;
if (SaveDlg->Execute())
{
f=fopen(SaveDlg->FileName.c_str(),"wb+");
SaveAll(f);
fclose(f);
}
}
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.