📄 g_func.cpp
字号:
#include <time.h>
#include <string.h>
#include <graphics.h>
#include <stdio.h>
#include "global.h"
#include "g_func.h"
#include "rd7472.h"
#include "coord.h"
extern float conv(int);
extern void Outchar45(int,int,char*,unsigned char );
void draw_dotted_line()
{
unsigned linepattern=0x0;
int style=DOTTED_LINE,width=NORM_WIDTH;
disable();
setlinestyle(style,linepattern,width);
for(int i=0;i<9;i++)
line(A_LX,A_LY+40*(i+1),A_RX,A_LY+40*(i+1));
for(i=0;i<9;i++)
line(A_LX+(i+1)*50,A_LY,A_LX+(i+1)*50,A_RY);
setlinestyle(SOLID_LINE,linepattern,width);
enable();
}
void draw_dotted_border(int leftx,int lefty,int rightx,int righty)
{
unsigned linepattern=0x0;
int style=DOTTED_LINE,width=NORM_WIDTH;
disable();
setlinestyle(style,linepattern,width);
line(leftx,lefty,rightx,lefty);
line(leftx,lefty,leftx,righty);
line(leftx,righty,rightx,righty);
line(rightx,lefty,rightx,righty);
setlinestyle(SOLID_LINE,linepattern,width);
enable();
}
void draw_border(int leftx,int lefty,int rightx,int righty)
{
disable();
// setcolor(2);
line(leftx,lefty,rightx,lefty);
line(leftx,lefty,leftx,righty);
line(leftx,righty,rightx,righty);
line(rightx,lefty,rightx,righty);
enable();
}
void draw_smal_border(int i)
{
// disable();
setcolor(GREEN);
rectangle(B_LX+1,i*59+7,B_RX-1,i*59+29);
// line(B_LX-1,i*59+8-5-1,B_RX-2,i*59+8-5-1);
// line(B_LX-1,i*59+8-5-1,B_LX-1,i*59+8+15+1);
// line(B_LX-1,i*59+8+15+1,B_RX-2,i*59+8+15+1);
// line(B_RX-2,i*59+8-5-1,B_RX-2,i*59+8+15+1);
// enable();
}
void draw_big_border(int i)
{
// disable();
// setcolor(2);
// line(B_LX-1,i*59+8-5-1,B_RX-2,i*59+8-5-1);
// line(B_LX-1,i*59+8-5-1,B_LX-1,i*59+8+15+20+1);
// line(B_LX-1,i*59+8+15+20+1,B_RX-2,i*59+8+15+20+1);
// line(B_RX-2,i*59+8-5-1,B_RX-2,i*59+8+15+20+1);
// enable();
setcolor(GREEN);
rectangle(B_LX+1,i*59-1,B_RX-1,i*59+41);
}
void draw_triangle(int i,int second)
{
int step;
if(_disp.disp_way==0)
step=40;
else if(_disp.disp_way==2)
step=32;
else
return;
if(second==0){
clear_rect(0,A_LY+step*(10-i)-6,A_LX-5,A_LY+step*(10-i)+6);
clear_rect(0,A_LY+step*(10-i)-6,A_LX-5,A_LY+step*(10-i)+6);
disable();
line(A_LX-20,A_LY+step*(10-i)-5,A_LX-10,A_LY+step*(10-i));
line(A_LX-20,A_LY+step*(10-i)-5,A_LX-20,A_LY+step*(10-i)+5);
line(A_LX-20,A_LY+step*(10-i)+5,A_LX-10,A_LY+step*(10-i));
enable();
if(ch_sel==0){
setcolor(_system.colora);
outtextxy(8,A_LY+step*(10-i)-3,"A");
}
else {
setcolor(_system.colorb);
outtextxy(8,A_LY+step*(10-i)-3,"B");
}
}
else if(second==1){
clear_rect(0,A_LY+step*(10-i)-6+15,A_LX-5,A_LY+step*(10-i)+6+15);
clear_rect(0,A_LY+step*(10-i)-6+15,A_LX-5,A_LY+step*(10-i)+6+15);
disable();
line(A_LX-20,A_LY+step*(10-i)-5+15,A_LX-10,A_LY+step*(10-i)+15);
line(A_LX-20,A_LY+step*(10-i)-5+15,A_LX-20,A_LY+step*(10-i)+5+15);
line(A_LX-20,A_LY+step*(10-i)+5+15,A_LX-10,A_LY+step*(10-i)+15);
enable();
if(ch_sel==1){
setcolor(_system.colora);
outtextxy(8,A_LY+step*(10-i)-3+15,"A");
}
else {
setcolor(_system.colorb);
outtextxy(8,A_LY+step*(10-i)-3+15,"B");
}
}
}
void erase_smal_border(int i)
{
// line(B_LX-1,i*59+8-5-1,B_RX-2,i*59+8-5-1);
setcolor(BLACK);
rectangle(B_LX+1,i*59+7,B_RX-1,i*59+29);
// clear_rect(B_LX-1,c*59+8-5-1,B_RX-2,c*59+8-5-1);
// clear_rect(B_LX-1,c*59+8-5-1,B_LX-1,c*59+8+15+1);
// clear_rect(B_LX-1,c*59+8+15+1,B_RX-2,c*59+8+15+1);
// clear_rect(B_RX-2,c*59+8-5-1,B_RX-2,c*59+8+15+1);
}
// line(B_LX-1,i*59+8-5-1,B_RX-2,i*59+8-5-1);
// line(B_LX-1,i*59+8-5-1,B_LX-1,i*59+8+15+1);
// line(B_LX-1,i*59+8+15+1,B_RX-2,i*59+8+15+1);
// line(B_RX-2,i*59+8-5-1,B_RX-2,i*59+8+15+1);
void erase_big_border(int i)
{
// disable();
setcolor(BLACK);
rectangle(B_LX+1,i*59-1,B_RX-1,i*59+41);
// line(B_LX-1,c*59+8-5-1,B_RX-2,c*59+8-5-1);
// line(B_LX-1,c*59+8-5-1,B_LX-1,c*59+8+15+20+1);
// line(B_LX-1,c*59+8+15+20+1,B_RX-2,c*59+8+15+20+1);
// line(B_RX-2,c*59+8-5-1,B_RX-2,c*59+8+15+20+1);
// enable();
}
void draw_big_menu(char i,char count,char p1_font,char p2_font,char p3_font,char*p1,char*p2,char*p3)
{
if(i<1||i>7)
return;
int x=B_LX+2;
int y=i*59;
int y1,y2,y3;
if(count==2){
y1=y+5;
y2=y+22;
}
else if(count==3){
y1=y+3;
y2=y+18;
y3=y+29;
}
else
return;
int len;
setfillstyle(SOLID_FILL,TEXTMENUBK);
bar(x,y,x+85,y+40);
len=strlen(p1);
if(p1_font == 1) //Chinese
{
if(len==8)
Outchar45(x+10,y1,p1,TEXTMENU);
else
Outchar12(x+10,y1,p1,TEXTMENU);
}
else{
setcolor(TEXTMENU);
outtextxy(x+10,y1,p1);
}
len=strlen(p2);
if(p2_font == 1) //Chinese
{
if(len==8)
Outchar45(x+6,y2,p2,TEXTMENU);
else
Outchar12(x+6,y2,p2,TEXTMENU);
}
else{
setcolor(TEXTMENU);
outtextxy(x+6,y2,p2);
}
if(count==3){
len=strlen(p3);
if(p3_font == 1) //Chinese
{
if(len==8)
Outchar45(x+6,y3,p3,TEXTMENU);
else
Outchar12(x+6,y3,p3,TEXTMENU);
}
else{
setcolor(TEXTMENU);
outtextxy(x+6,y3,p3);
}
}
}
void draw_small_menu(char i,char font,char*p)
{
if(i<1||i>7)
return;
setfillstyle(SOLID_FILL,TEXTMENUBK);
bar(B_LX+2,i*59+8,B_RX-2,i*59+28);
if(font==1) //Chinese
{
Outchar12(B_LX+12,i*59+12,p,TEXTMENU);
}
else{
setcolor(TEXTMENU);
outtextxy(B_LX+12,i*59+14,p);
}
}
void clear_rect(int left, int top, int right, int bottom)
{
int oldClr;
struct fillsettingstype fillInfo;
int COLOR_SET=0;
// disable();
oldClr = getcolor();
getfillsettings(&fillInfo);
setcolor(COLOR_SET);
setfillstyle(SOLID_FILL, COLOR_SET);
// disable();
bar(left, top, right, bottom);
setcolor(oldClr);
// disable();
setfillstyle(fillInfo.pattern, fillInfo.color);
// enable();
}
void disp_menu(char *ss[],int n)
{
clear_rect(B_LX+1,B_LY+1,B_RX-1,B_RY-1);
clear_rect(B_LX+1,B_LY+1,B_RX-1,B_RY-1); ////strange
char *p,*q;
for(int i=0;i<n;i++)
{
p=ss[i];
q=p;
for(;*p;p++)
if(*p=='&') {*p='\0'; p++; break;}
Outchar12(B_LX+10,B_LY+(i+1)*50,q,0xf);
Outchar12(B_LX+10,B_LY+(i+1)*50+16,p,0xf);
}
}
void write_line(char chan_sel)
{
char y;
char color;
char msg[20];
if(chan_sel==0){
y = 3;
color = _system.colora;
}
else{
y=16;
color =_system.colorb;
}
Outchar12(35,y,"踪迹 :",color);
Outchar12(61,y,chan_sel==0?"A":"B",color);
if(_chab[chan_sel].on_off == ON){
Outchar12(87,y,_chab[chan_sel].flag==0?"幅频特性":"功率测量",color);
Outchar12(165,y,_disp.flag1==0?"对数":"线性",color);
Outchar12(217,y,"功率:",color);
sprintf(msg,"%.2fdBm",_power[chan_sel].output_power);
// disable();
setcolor(color);
outtextxy(256,y+2,msg);
sprintf(msg,"%.1f/",_scale[chan_sel].scale_unit);
// disable();
setcolor(color);
outtextxy(351,y+2,msg);
Outchar12(393,y,"格",color);
Outchar12(437,y,"参考:",color);
if(_chab[chan_sel].flag==0)
sprintf(msg,"%.1fdB",_scale[chan_sel].ref_vol);
else
sprintf(msg,"%.1fdBm",_scale[chan_sel].ref_vol);
// disable();
setcolor(color);
outtextxy(476,y+2,msg);
}
else
Outchar12(87,y,"关",color);
}
void refresh_up()
{ // printf("\n\n\n\n %d %d",TEXTFRTLN,TEXTSEDLN);
clear_rect(35,1,540,30);
clear_rect(35,1,540,30);
// if(ch_sel==0||aternative==ON){
write_line(0);
// }
// if(ch_sel==1||alternative == ON){
write_line(1);
// }
/* if(ch_sel==0)
{
if(_chab[ch_sel].on_off==ON)
{ if(_chab[!ch_sel].on_off==ON)
onaab();
else if(_chab[!ch_sel].on_off==OFF)
{
Outchar12(35,17,"踪迹B: 关",TEXTSEDLN);
offb_ona(ch_sel);
}
}
else if(_chab[ch_sel].on_off==OFF)
{ Outchar12(35,3,"踪迹A: 关",TEXTFRTLN);
if(_chab[!ch_sel].on_off==ON)
offa_onb(ch_sel);
else if(_chab[!ch_sel].on_off==OFF)
Outchar12(35,17,"踪迹B: 关",TEXTSEDLN);
}
}
else if(ch_sel==1)
{
if(_chab[ch_sel].on_off==ON)
{ if(_chab[!ch_sel].on_off==ON)
onabb();
else if(_chab[!ch_sel].on_off==OFF)
{
Outchar12(35,3,"踪迹A: 关",TEXTFRTLN);
offa_onb(ch_sel);
}
}
else if(_chab[ch_sel].on_off==OFF)
{ Outchar12(35,17,"踪迹B: 关",TEXTSEDLN);
if(_chab[!ch_sel].on_off==ON)
offb_ona(ch_sel);
else if(_chab[!ch_sel].on_off==OFF)
Outchar12(35,3,"踪迹A: 关",TEXTFRTLN);
}
}*/
}
void onaab()
{ char msg[20];
Outchar12(35,3,"踪迹A: /格 参考: ",TEXTFRTLN);
Outchar12(35,17,"踪迹B: /格 参考: ",TEXTSEDLN);
sprintf(msg,"%.1f",_scale[ch_sel].scale_unit);
disable();
setcolor(TEXTFRTLN);
outtextxy(290,6,msg);
sprintf(msg,"%.1f",_scale[ch_sel].ref_vol);
disable();
outtextxy(460,6,msg);
setcolor(TEXTSEDLN);
sprintf(msg,"%.1f",_scale[!ch_sel].scale_unit);
disable();
outtextxy(290,20,msg);
sprintf(msg,"%.1f",_scale[!ch_sel].ref_vol);
disable();
outtextxy(460,20,msg);
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(_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(_disp.flag1==0){
Outchar12(206,3,"对数",TEXTFRTLN);
Outchar12(206,17,"对数",TEXTSEDLN);
}
else if(_disp.flag1==1){
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,3,"幅频特性",TEXTFRTLN);
else if(_chab[ch_sel].flag==1)
Outchar12(100,3,"功率测量",TEXTFRTLN);
else if(_chab[ch_sel].flag==2)
Outchar12(100,3,"转换损耗",TEXTFRTLN);
cotr_selb(1);
}
void onabb()
{ char msg[20];
Outchar12(35,3,"踪迹A: /格 参考: ",TEXTFRTLN);
Outchar12(35,17,"踪迹B: /格 参考: ",TEXTSEDLN);
sprintf(msg,"%.1f",_scale[!ch_sel].scale_unit);
disable();
setcolor(TEXTFRTLN);
outtextxy(290,6,msg);
sprintf(msg,"%.1f",_scale[!ch_sel].ref_vol);
outtextxy(460,6,msg);
setcolor(TEXTSEDLN);
sprintf(msg,"%.1f",_scale[ch_sel].scale_unit);
disable();
outtextxy(290,20,msg);
sprintf(msg,"%.1f",_scale[ch_sel].ref_vol);
outtextxy(460,20,msg);
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(_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(_disp.flag1==0){
Outchar12(206,3,"对数",TEXTFRTLN);
Outchar12(206,17,"对数",TEXTSEDLN);
}
else if(_disp.flag1==1){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -