📄 g_func.cpp
字号:
Outchar12(206,3,"线性",TEXTFRTLN);
Outchar12(206,17,"线性",TEXTSEDLN);
}
// if(_format[!ch_sel].flag1==0)
// Outchar12(206,17,"对数",TEXTSEDLN);
// else if(_format[!ch_sel].flag1==1)
// Outchar12(206,17,"线性",TEXTSEDLN);
clear_rect(100,3,150,29);
if(_chab[ch_sel].flag==0)
Outchar12(100,17,"幅频特性",TEXTSEDLN);
else if(_chab[ch_sel].flag==1)
Outchar12(100,17,"功率测量",TEXTSEDLN);
else if(_chab[ch_sel].flag==2)
Outchar12(100,17,"转换损耗",TEXTSEDLN);
cotr_sela(0);
}
void offa_onb(int i)
{ int t;
char msg[20];
if(i==0)
{ t=TEXTSEDLN;
setcolor(t);
sprintf(msg,"%.1f",_scale[!i].scale_unit);
disable();
outtextxy(290,20,msg);
sprintf(msg,"%.1f",_scale[!i].ref_vol);
outtextxy(460,20,msg);
Outchar12(35,17,"踪迹B: /格 参考: ",t);
if(_chab[1].flag==0||_chab[1].flag==2)
Outchar12(502,17,"dB",TEXTSEDLN);
else if(_chab[1].flag==1)
Outchar12(502,17,"dBm",TEXTSEDLN);
}
else if(i==1)
{ t=TEXTSEDLN;
setcolor(t);
sprintf(msg,"%.1f",_scale[i].scale_unit);
disable();
outtextxy(290,20,msg);
sprintf(msg,"%.1f",_scale[i].ref_vol);
outtextxy(460,20,msg);
Outchar12(35,17,"踪迹B: /格 参考: ",t);
if(_chab[1].flag==0||_chab[1].flag==2)
Outchar12(502,17,"dB",TEXTSEDLN);
else if(_chab[1].flag==1)
Outchar12(502,17,"dBm",TEXTSEDLN);
}
// if(_format[!ch_sel].flag1==0)
// Outchar12(206,17,"对数",t);
// else if(_format[!ch_sel].flag1==1)
// Outchar12(206,17,"线性",t);
cotr_selb(1);
}
void offb_ona(int i)
{ int t; char msg[20]; if(i==0)
{ t=TEXTFRTLN;
setcolor(t);
sprintf(msg,"%.1f",_scale[ch_sel].scale_unit);
disable();
outtextxy(290,6,msg);
sprintf(msg,"%.1f",_scale[ch_sel].ref_vol);
outtextxy(460,6,msg);
Outchar12(35,3,"踪迹A: /格 参考: ",TEXTFRTLN);
}
else if(i==1)
{ t=TEXTSEDLN;
setcolor(TEXTFRTLN);
sprintf(msg,"%.1f",_scale[!ch_sel].scale_unit);
disable();
outtextxy(290,6,msg);
sprintf(msg,"%.1f",_scale[!ch_sel].ref_vol);
outtextxy(460,6,msg);
Outchar12(35,3,"踪迹A: /格 参考: ",TEXTFRTLN);
}
if(_chab[0].flag==0||_chab[0].flag==2)
Outchar12(502,3,"dB",TEXTFRTLN);
else if(_chab[0].flag==1)
Outchar12(502,3,"dBm",TEXTFRTLN);
if(_disp.flag1==0)
Outchar12(206,3,"对数",TEXTFRTLN);
else if(_disp.flag1==1)
Outchar12(206,3,"线性",TEXTFRTLN);
cotr_sela(0);
}
void cotr_selb(int ch_sel)
{
if(_chab[ch_sel].flag==0)
Outchar12(100,17,"幅频特性",TEXTSEDLN);
else if(_chab[ch_sel].flag==1)
Outchar12(100,17,"功率测量",TEXTSEDLN);
else if(_chab[ch_sel].flag==2)
Outchar12(100,17,"转换损耗",TEXTSEDLN);
}
void cotr_sela(int ch_sel)
{
if(_chab[ch_sel].flag==0)
Outchar12(100,3,"幅频特性",TEXTFRTLN);
else if(_chab[ch_sel].flag==1)
Outchar12(100,3,"功率测量",TEXTFRTLN);
else if(_chab[ch_sel].flag==2)
Outchar12(100,3,"转换损耗",TEXTFRTLN);
}
void disp_menu12(char *ss[],int n)
{
char *p,*q;
int flag=0;
int color=TEXTMENU;
clear_rect(B_LX-1,0,B_RX,B_RY+6);
clear_rect(B_LX-1,0,B_RX,B_RY+6); //twice
setcolor(TEXTMENUFRAME);
draw_border(B_LX,B_LY-30,B_RX,B_LY-5);
draw_border(B_LX+1,B_LY-30+1,B_RX-1,B_LY-5-1);
draw_border(B_LX+2,B_LY-30+2,B_RX-2,B_LY-5-2);
Outchar12(B_LX+15,B_LY-23,ss[0],RED);
for(int i=1;i<=n;i++)
{
p=ss[i];
if(*p)
{
q=p;
for(;*p;p++)
if(*p=='&')
{
*p++='\0';
flag=1;
break;
}
setfillstyle(SOLID_FILL,TEXTMENUBK);
bar(B_LX+2,i*59+8,B_RX-2,i*59+28);
if(strlen(q)==8)
Outchar45(B_LX+12,i*59+12,q,color);
else
Outchar12(B_LX+12,i*59+12,q,color);
//if(*p)
//{
// bar(B_LX,i*59+8-5+18,B_RX-3,i*59+8+20+15);
// Outchar12(B_LX+10,i*59+8+20,p,color);
//}
if(flag==1)
{
flag=0;
*(p-1)='&';
}
}
}
}
/*
void disp_menu_vice(int x1,int y1,int x2,int y2,char *s1,int color1,char *s2,int color2)
{
char *p=s1,*q=s2;
disable();
clear_rect(x1,y1,x2,y2);
setfillstyle(SOLID_FILL,TEXTMENUBK);
bar(x1,y1,x2,y2);
Outchar12(x1,y1,p,color1);
Outchar12(x1,y1,q,color2);
enable();
}
*/
void disp_time()
{
char msg[22],msg1[6];
// clear_rect(545,445,639,475);
// clear_rect(545,445,639,475);
/* if(_disp.time_disp==0){
//*********************************modify by zxg 2004/5/21
// struct tm *ptr;
// time_t lt;
// lt=time(NULL);
// ptr=gmtime(<);
int second=_system.t.ti_sec;
gettime(&_system.t);
if(_system.t.ti_sec!=second){
clear_rect(545,445,639,479);
clear_rect(545,445,639,479);
sprintf(msg,"%02d",_system.t.ti_hour);
sprintf(msg1,":%02d",_system.t.ti_min);
strcat(msg,msg1);
sprintf(msg1,":%02d",_system.t.ti_sec);
strcat(msg,msg1);
setcolor(RED);
disable();
outtextxy(562,466,msg);
enable();
getdate(&_system.d);
sprintf(msg,"%d",_system.d.da_year);
sprintf(msg1,"-%02d",_system.d.da_mon);
strcat(msg,msg1);
sprintf(msg1,"-%02d",_system.d.da_day);
strcat(msg,msg1);
setcolor(RED);
disable();
outtextxy(552,450,msg);
enable();
}
// _system.d.da_year=ptr->tm_year+1900;
// _system.d.da_mon=ptr->tm_mon+1;
// _system.d.da_day=ptr->tm_mday;
// _system.t.ti_hour=24-ptr->tm_hour;
// _system.t.ti_min=ptr->tm_min;
//_system.sys_time.second=ptr->tm_sec;
//************************************
}
*/
}
void draw_marker(int x,int y,MDAMAP *mda_map)
{
if(y>DISP_Y2-36||y<DISP_Y1-36)
return;
if(_disp.disp_way==1||_sweep[chs].flag1==1)
return;
if(x>=DISP_X1&&x<=DISP_X2+1){
if(y>=16+1&&y<=DISP_Y2-36){
disable();
mda_map->Line(x,y,x+4,y-8-1,(chs==0?_system.colora:_system.colorb));
mda_map->Line(x,y-1,x-4,y-8-1,(chs==0?_system.colora:_system.colorb));
mda_map->Line(x-4,y-8-1,x+4,y-8-1,(chs==0?_system.colora:_system.colorb));
enable();
}
else if(y>=0){
disable();
mda_map->Line(x,y+1,x+4,y+8+1,(chs==0?_system.colora:_system.colorb));
mda_map->Line(x,y+1,x-4,y+8+1,(chs==0?_system.colora:_system.colorb));
mda_map->Line(x-4,y+8+1,x+4,y+8+1,(chs==0?_system.colora:_system.colorb));
enable();
}
}
}
void wrt_num(char *str,int x,int y,int color,MDAMAP* mda_map)
{
char msg[2];
int text_y,xm;
msg[1]='\0';
if(_disp.disp_way==1||_sweep[chs].flag1==1)
return;
if(y>DISP_Y2-36)
return;
if(_disp.disp_way==2)
y*=0.8;
if(x>=DISP_X1&&x<=DISP_X2+1){
if(strlen(str)==1){
if(y>16&&y<=DISP_Y2-36){
disable();
setcolor(color);
// mda_map->Line(DISP_X1+1,DISP_Y2+1,DISP_X2-1,DISP_Y2+1);///strange???
mda_map->Line(0,0,0,0,(chs==0?_system.colora:_system.colorb));///strange???
outtextxy(x-3,y+20-1,str);
enable();
}
// else if(y>=DISP_Y1){
else if(y>=0){
disable();
setcolor(color);
// mda_map->Line(DISP_X1+1,DISP_Y2+1,DISP_X2-1,DISP_Y2+1);///strange???
mda_map->Line(0,0,0,0,(chs==0?_system.colora:_system.colorb));///strange???
outtextxy(x-3,y+48+1,str);
enable();
}
}
else if(strlen(str)==3){
if(x>DISP_X2-16)
xm=20;
else if(x<DISP_X1+16)
xm=3;
else
xm=11;
if(y>=(16+1)&&y<=DISP_Y2-36){
text_y=y+20-1;
}
else if(y>=0&&y<=DISP_Y2-36){
text_y=y+48-1;
}
else
return;
setcolor(color);
msg[0]=str[0];
disable();
setcolor(color);
mda_map->Line(0,0,0,0,(chs==0?_system.colora:_system.colorb));///strange???
// mda_map->Line(DISP_X1+1,DISP_Y2+1,DISP_X2-1,DISP_Y2+1);///strange???
outtextxy(x-xm,text_y,msg);
msg[0]=str[1];
disable();
setcolor(color);
mda_map->Line(0,0,0,0,(chs==0?_system.colora:_system.colorb));///strange???
// mda_map->Line(DISP_X1+1,DISP_Y2+1,DISP_X2-1,DISP_Y2+1);///strange???
outtextxy(x-xm+8,text_y,msg);
msg[0]=str[2];
disable();
setcolor(color);
mda_map->Line(0,0,0,0,(chs==0?_system.colora:_system.colorb));///strange???
// mda_map->Line(DISP_X1+1,DISP_Y2+1,DISP_X2-1,DISP_Y2+1);///strange???
outtextxy(x-xm+16,text_y,msg);
enable();
}
}
}
float Max(char chan_sel,struct coordinate &max_coor,long &freq)
{
int temp_i = 0;
int max = chan_sel==0?y_a[0]:y_b[0];
for(int i=1;i<_status[chan_sel].sweep_points;i++)
if(max<(chan_sel==0?y_a[i]:y_b[i])){
max = (chan_sel==0?y_a[i]:y_b[i]);
temp_i = i;
}
float max_f = conv(max);
draw_map(_status[chan_sel].sweep_points,i,max_f);
max_coor.x = x_map;
max_coor.y = y_map;
freq = _freq[chan_sel].start_freq + (double)_freq[chan_sel].freq_width/_status[chan_sel].sweep_points*temp_i;
return max_f;
}
float Min(char chan_sel,struct coordinate &min_coor,long &freq)
{
int temp_i = 0;
int min = chan_sel==0?y_a[0]:y_b[0];
for(int i=1;i<_status[chan_sel].sweep_points;i++)
if(min>(chan_sel==0?y_a[i]:y_b[i])){
min = (chan_sel==0?y_a[i]:y_b[i]);
temp_i = i;
}
float min_f = conv(min);
draw_map(_status[chan_sel].sweep_points,i,min_f);
min_coor.x = x_map;
min_coor.y = y_map;
freq = _freq[chan_sel].start_freq + (double)_freq[chan_sel].freq_width/_status[chan_sel].sweep_points*temp_i;
return min_f;
}
float Max(long freq1,long freq2,char chan_sel)
{
if(_freq[chan_sel].is_dot_freq)
return conv(chan_sel==0?y_a[0]:y_b[0]);
if(freq1<_freq[chan_sel].start_freq)
freq1 = _freq[chan_sel].start_freq;
else if(freq1>_freq[chan_sel].end_freq)
freq1 = _freq[chan_sel].end_freq;
if(freq2<_freq[chan_sel].start_freq)
freq2 = _freq[chan_sel].start_freq;
else if(freq2>_freq[chan_sel].end_freq)
freq2 = _freq[chan_sel].end_freq;
int index1 = (int)((double)(freq1-_freq[chan_sel].start_freq)
/_freq[chan_sel].freq_width*(_status[chan_sel].sweep_points-1));
if(index1<0)
index1 = 0;
else if(index1>_status[chan_sel].sweep_points-1)
index1 = _status[chan_sel].sweep_points-1;
int index2 = (int)((double)(freq2-_freq[chan_sel].start_freq)
/_freq[chan_sel].freq_width*(_status[chan_sel].sweep_points-1));
if(index2<0)
index2 = 0;
else if(index2>_status[chan_sel].sweep_points-1)
index2 = _status[chan_sel].sweep_points-1;
if(index1>index2){
int temp = index1;
index1 = index2;
index2 = temp;
}
int max = chan_sel==0?y_a[index1]:y_b[index1];
for(int i = index1+1;i <= index2;i++){
if(max<(chan_sel==0?y_a[i]:y_b[i]))
max = (chan_sel==0?y_a[i]:y_b[i]);
}
return conv(max);
}
float Min(long freq1,long freq2,char chan_sel)
{
if(_freq[chan_sel].is_dot_freq){
return conv(chan_sel==0?y_a[0]:y_b[0]);
}
if(freq1<_freq[chan_sel].start_freq)
freq1 = _freq[chan_sel].start_freq;
else if(freq1>_freq[chan_sel].end_freq)
freq1 = _freq[chan_sel].end_freq;
if(freq2<_freq[chan_sel].start_freq)
freq2 = _freq[chan_sel].start_freq;
else if(freq2>_freq[chan_sel].end_freq)
freq2 = _freq[chan_sel].end_freq;
int index1 = (int)((double)(freq1-_freq[chan_sel].start_freq)
/_freq[chan_sel].freq_width*(_status[chan_sel].sweep_points-1));
if(index1<0)
index1 = 0;
else if(index1>_status[chan_sel].sweep_points-1)
index1 = _status[chan_sel].sweep_points-1;
int index2 = (int)((double)(freq2-_freq[chan_sel].start_freq)
/_freq[chan_sel].freq_width*(_status[chan_sel].sweep_points-1));
if(index2<0)
index2 = 0;
else if(index2>_status[chan_sel].sweep_points-1)
index2 = _status[chan_sel].sweep_points-1;
if(index1>index2){
int temp = index1;
index1 = index2;
index2 = temp;
}
int min = chan_sel==0?y_a[index1]:y_b[index1];
for(int i = index1+1;i <= index2;i++){
if(min>(chan_sel==0?y_a[i]:y_b[i]))
min = (chan_sel==0?y_a[i]:y_b[i]);
}
return conv(min);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -