//========================================================================================================= // // semia_stubs.cc // // F. Jager and R. Dorn 20 May 2002 // Last revised: 5 September 2002 // // Callback and user functions of SEMIA (SEMI-Automatic viewer and annotation editor), Version 3.0.1 // // ------------------------------------------------------------------------------- // SEMIA: SEMI-Automatic viewer and annotation editor // SEMIA, Version 3.0.1: SEMI-Automatic viewer of waveforms, time series, and // ST-segment annotations in the Long-Term ST Database // // Copyright (C) 2002 Franc Jager and Roman Dorn // // This program is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free Software // Foundation; either version 2 of the License, or (at your option) any later // version. // // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along with // this program; if not, write to the Free Software Foundation, Inc., 59 Temple // Place - Suite 330, Boston, MA 02111-1307, USA. // // You may contact the author by e-mail (franc@manca.fri.uni-lj.si) or postal // mail (Faculty of Computer and Information Science, Trzaska 25, 1000 Ljubljana, // Slovenia). For updates to this software, please visit PhysioNet // (http://www.physionet.org/). // ------------------------------------------------------------------------------- // #include #include #include #include #include #include #include #include #include #include #include #define _OTHER_TEXTSW_FUNCTIONS #include #include #include #include #include "semia_ui.h" //Work with WFDB library #include #include #include //How to plot time series #define PLOT_ALL FALSE //Length of one screen in samples if Fsamp is 250 samples/sec //Lengths 21600000 - 24 hours // 43200000 - 48 hours //Length of fine buffers if Fsamp is 250 samples/sec (LEN_BUFF_F) //Lengths 187200 (190000) - 26 hours // 345600 (370000) - 48 hours //Length of raw buffers if Fsamp is 250 samples/sec (LEN_BUFF_R) //Lengths 46800 (47000) - 26 hours // 86400 (90000) - 48 hours #define LEN_BUFF_F 224000 // fine data buff length #define LEN_BUFF_R 86400 // raw data buff length // #define STAMPL 200 // 200 units = 1000 uV #define FSAMP 250 // 250 msec #define auto_ampl_1 10.0 // 50 uV #define BORDER_SEP_CLICK 120 // Samples at the bottom of lead window #define ALL_ONE FALSE // true = copy lead0 > lead1 > lead2 #define LEN_BUFF_D 37626 // 5 min / 2 = 150 * 1000 msec = 150 * 1000 / (1000/FSAMP) + 125 (avr /2 ) + 1 ( center ) #define LEN_BUFF_D_A 251 // average window = 1000 msec #define OR || void d_ini_cp_b(Panel_item, Event *); void l_ini_cp1_b(Panel_item, Event *); void k_ini_cp_b(Panel_item, Event *); void l_ini_cp2_b(Panel_item, Event *); void main_open_init(Panel_item, Event *); void init_counts(Panel_item, Event *); void init_diagdata(Panel_item, Event *); void show_diagdata(Panel_item, Event *); void show_counts(Panel_item, Event *); void init_help(Panel_item, Event *); void show_help(Panel_item, Event *); //Global variables for drawing Display *l_b_display, *l_b1_display, *l_b2_display, *d_b_display, *k_b_display, *my_display; Window l_b_window, l_b1_window, l_b2_window, d_b_window, k_b_window, my_window; GC gcLead0, gcLead1, gcLead2, gcdata, gckoeff, my_gc; unsigned long background, foreground; Colormap cmap; XColor col, unused; //Global data int set_line_width=1; int set_marker=1; char set_color1[30]="green"; char set_color2[30]="blue"; char set_color3[30]="red"; char set_color4[30]="red"; char set_color5[30]="red"; char set_color6[30]="red"; //Other char set_color7[30]="LightCyan1"; char set_color8[30]="yellow"; long click_ST80_0 = 0, click_STsb_0 = 0, click_ST80_f0 = 0; long click_ST80_1 = 0, click_STsb_1 = 0, click_ST80_f1 = 0; long click_ST80_2 = 0, click_STsb_2 = 0, click_ST80_f2 = 0; Bool auto_save = FALSE; int auto_save_counter = 0; Bool fast0_center = FALSE; Bool fast1_center = FALSE; Bool fast2_center = FALSE; Bool fast0_right = FALSE; Bool fast1_right = FALSE; Bool fast2_right = FALSE; char message[60], message1[60], message2[60], message3[60]; char pr_buff[80]; //Input data variables char inp_rec_name[80]; WFDB_Siginfo *siarray; long nsig; WFDB_Siginfo DB_s[WFDB_MAXSIG]; WFDB_Sample v_sample[3]; FILE *dataFileDescriptor = NULL; long buff[5][15000]; //Save FILE *file_save=NULL; FILE *flinsave=NULL; char save_name[20]; char save_name_lin[20]; Bool final_save = FALSE; //Program status Bool status_manual_mode=TRUE, status_unsubtracted=TRUE, status_consider_localref=TRUE; Bool status_manual_mode1=TRUE, status_unsubtracted1=TRUE, status_consider_localref1=TRUE; Bool status_manual_mode2=TRUE, status_unsubtracted2=TRUE, status_consider_localref2=TRUE; //Diagram data long time_scale_0=720, time_scale_1=720, time_scale_2=720; // 720 = 12 min long time_scale_d=6; // 6 = 6sec int data_scale=6; // 6 = 6 sec long data_tick=160; double data_grid_tick = 25.6; // 6 sec / 960 * 25.6 = 160 msec long scale_time_tick=60; // 720 / 12 = 60 long diagram_time_begin_lead, diagram_time_end_lead; long time_begin_lead, time_end_lead; long ampl_0=100, ampl_1=100, ampl_2=100; // 100 = 100uV long ampl_d=1000; long auto_ampl_2[3]; float ampl_c=1.0; long index_0, index_0_b, index_0_e; long raw_last_index, fin_last_index; long raw_display_begin, raw_display_end, fin_display_begin, fin_display_end; Bool ovr0_l1=FALSE, ovr0_l2=FALSE; Bool ovr1_l0=FALSE, ovr1_l2=FALSE; Bool ovr2_l1=FALSE, ovr2_l0=FALSE; Bool ovr0_app = FALSE, ovr1_app = FALSE, ovr2_app = FALSE; Bool lead1_data=FALSE, lead2_data=FALSE; Bool KL_coefficents=TRUE; Bool ovr_coef=FALSE; Bool allow_l0; Bool allow_l1, allow_l2; Bool x_lead =FALSE; short Lead0_operation; short Lead1_operation; short Lead2_operation; Bool change_atribute0=FALSE; Bool change_atribute1=FALSE; Bool change_atribute2=FALSE; Bool how0=TRUE; Bool how1=TRUE; Bool how2=TRUE; char ref_code[5]; int Data_lead=0; Bool data_ovr_l0, data_ovr_l1, data_ovr_l2; Bool data_ovrly_shift; long data_mstime_index, reference_mstime_index; long L_buff_M[6][LEN_BUFF_D], R_buff_M[6][LEN_BUFF_D],A_buff_M[6][LEN_BUFF_D_A]; long L_buff_R[6][LEN_BUFF_D], R_buff_R[6][LEN_BUFF_D],A_buff_R[6][LEN_BUFF_D_A]; Bool global_set; Bool last_set_all; int current_iso_m, current_j_m; long current_nl, current_nr, current_mean_smp; long ref_iso, ref_j, ref_dj; long current_average_beat_time = 0; long d_avrg_index = 0; long current_average_window_index; long current_average_window_time; short data_ovrly=1; Bool data_ovr_ref=FALSE; Bool repeat_set =FALSE; Bool repeat_set1=FALSE; Bool repeat_set2=FALSE; class def_click { public: Bool first; long x,y, time_index, raw, raw_l,raw_r, fine, fine_l, fine_r; }; def_click click_l0, click_c0, click_r0; def_click click_l1, click_c1, click_r1; def_click click_l2, click_c2, click_r2; def_click click_c; class button_lead_status_def { public: Bool Mark,Dmy, Auto, Subtr, Cmpt, OvrApp, OvrLds, GlR, SetLB, SetLE, DelLI, Isc, Rate_r, Cnd, AxS,Exm, Atr, Move, Del, DelA, ChAtr,ChAtrA, ConsLR, LcRef, Cancel, Rpt; short Auto_s,Subtr_s,OvrApp_s,ConsLR_s; void copy_button_status( button_lead_status_def source); }; button_lead_status_def Lead0_buttons, Lead0_op_begin_status; button_lead_status_def Lead1_buttons, Lead1_op_begin_status; button_lead_status_def Lead2_buttons, Lead2_op_begin_status; class data_fin_def { public: long index; int HR; float l0_ST80,l0_ST20,l1_ST80,l1_ST20,l2_ST80,l2_ST20; int STk1,STk2,STk3,STk4,STk5, ST_f, QRSk1,QRSk2,QRSk3,QRSk4,QRSk5, QRS_f, nPB, nPE, nISO, nQ, nJ, nTB, nTX, nTE; float lin_v[3], sub_v[3]; void Init(void); void Insert(data_fin_def value); }; data_fin_def data_fin[LEN_BUFF_F]; data_fin_def data_raw[LEN_BUFF_R]; class lead_plot_button_status { public: Bool HRate,HRRaw,STFine,STslFine,STslRaw,Episodes,HideHR,ISOJ,Mode9,Mode10,lead0,lead1,lead2,UnOvrly; }; lead_plot_button_status lead0_plot_button_status; lead_plot_button_status lead1_plot_button_status; lead_plot_button_status lead2_plot_button_status; class reference_def { public: Bool set; long raw_index, fine_index; int code1, code2; int lead, raw_HR, fine_HR; int raw_ST80,raw_ST20, ST_sub, fine_ST80, fine_ST20, STd, ST80, STsl; int nPB, nPE, nISO, nQ, nJ, nJ80, nTB, nTX, nTE, window, NL, NR, NS; void copy_ref(reference_def source); }; reference_def global_ref[3], act_ref_data[3], Marker[3], references[3][5000], loc_interval_b[3], loc_interval_e[3]; long references_index[3]; long reference_act[3]; // last active reference - set or ex class ref_use_def { public: Bool set, change; long typ; // 1 - global, 2 - local long index, lead; }; ref_use_def act_reference[3]; void k_call_left(Xv_window, Event *, Notify_arg, Notify_event_type); void k_call_center(Xv_window, Event *, Notify_arg, Notify_event_type); void k_call_right(Xv_window, Event *, Notify_arg, Notify_event_type); void d_call_left(Xv_window, Event *, Notify_arg, Notify_event_type); void d_call_center(Xv_window, Event *, Notify_arg, Notify_event_type); void d_call_right(Xv_window, Event *, Notify_arg, Notify_event_type); void l_call_left(Xv_window, Event *, Notify_arg, Notify_event_type); void l_call_center(Xv_window, Event *, Notify_arg, Notify_event_type); void l_call_right(Xv_window, Event *, Notify_arg, Notify_event_type); void l_call_left1(Xv_window, Event *, Notify_arg, Notify_event_type); void l_call_center1(Xv_window, Event *, Notify_arg, Notify_event_type); void l_call_right1(Xv_window, Event *, Notify_arg, Notify_event_type); void l_call_left2(Xv_window, Event *, Notify_arg, Notify_event_type); void l_call_center2(Xv_window, Event *, Notify_arg, Notify_event_type); void l_call_right2(Xv_window, Event *, Notify_arg, Notify_event_type); void l_ini_lcp_b(Panel_item, Event *); void draw_grid_coeff(void); void draw_ovrly_coeff(void); void sub_op0_exec(void); void sub_op1_exec(void); void sub_op2_exec(void); void insert_ref(int, reference_def, int, int); void set_marker_l(int leadx); void update_marker(int leadx,long cal); void draw_grid_lead0(int leadx); void show_data(int leadx, Bool xx_lead, Bool xx_kl); void data_new_r_read(void); void get_average_M(void); void get_average_R(void); void set_buttons_lead1_setGR(void); void set_buttons_lead1(void); void set_buttons_lead2_setGR(void); void set_buttons_lead2(void); void set_buttons_lead0(void); //Global object definitions. sem_0_m_bw_objects Sem_0_m_bw; sem_0_k_bw_objects Sem_0_k_bw; sem_0_o_pw_objects Sem_0_o_pw; sem_0_q_pw_objects Sem_0_q_pw; sem_0_w_pw_objects Sem_0_w_pw; sem_0_d_bw_objects Sem_0_d_bw; sem_0_l_bw_objects Sem_0_l_bw; sem_0_l_bw1_objects Sem_0_l_bw1; sem_0_l_bw2_objects Sem_0_l_bw2; sem_0_d_pw_objects Sem_0_d_pw; sem_0_c_pw_objects Sem_0_c_pw; sem_0_h_pw_objects Sem_0_h_pw; //User functions ========================================================================================= //void (*textsw_default_notifyx)(Textsw textsw, Attr_avlist attributes); void myproc(Textsw textsw, Attr_avlist attributes) { int pass_on = FALSE; Attr_avlist attrs; for (attrs = attributes; *attrs; attrs = attr_next(attrs)) { // switch ((Textsw_action)(*attrs)) { // case TEXTSW_ACTION_TOOL_DESTROY: ATTR_CONSUME(*attrs); // break; // case TEXTSW_ACTION_TOOL_QUIT: // ATTR_CONSUME(*attrs); // break; // defaults: pass_on = TRUE; // break; // } } if (pass_on) textsw_default_notify(textsw, attributes); } void reset_HR_lead0(int leadx) { switch (leadx) { case 0: lead0_plot_button_status.HRate=FALSE; lead0_plot_button_status.HRRaw=FALSE; lead0_plot_button_status.STFine=FALSE; lead0_plot_button_status.STslFine=FALSE; lead0_plot_button_status.STslRaw=FALSE; lead0_plot_button_status.Episodes=FALSE; lead0_plot_button_status.HideHR=FALSE; lead0_plot_button_status.ISOJ=FALSE; lead0_plot_button_status.Mode9=FALSE; lead0_plot_button_status.Mode10=FALSE; break; case 1: lead1_plot_button_status.HRate=FALSE; lead1_plot_button_status.HRRaw=FALSE; lead1_plot_button_status.STFine=FALSE; lead1_plot_button_status.STslFine=FALSE; lead1_plot_button_status.STslRaw=FALSE; lead1_plot_button_status.Episodes=FALSE; lead1_plot_button_status.HideHR=FALSE; lead1_plot_button_status.ISOJ=FALSE; lead1_plot_button_status.Mode9=FALSE; lead1_plot_button_status.Mode10=FALSE; break; case 2: lead2_plot_button_status.HRate=FALSE; lead2_plot_button_status.HRRaw=FALSE; lead2_plot_button_status.STFine=FALSE; lead2_plot_button_status.STslFine=FALSE; lead2_plot_button_status.STslRaw=FALSE; lead2_plot_button_status.Episodes=FALSE; lead2_plot_button_status.HideHR=FALSE; lead2_plot_button_status.ISOJ=FALSE; lead2_plot_button_status.Mode9=FALSE; lead2_plot_button_status.Mode10=FALSE; break; } // end switch } void data_fin_def::Init(void) { index=0; HR=0; l0_ST80=0;l0_ST20=0; l1_ST80=0;l1_ST20=0; l2_ST80=0;l2_ST20=0; STk1=0;STk2=0;STk3=0;STk4=0;STk5=0; ST_f=0; QRSk1=0;QRSk2=0;QRSk3=0;QRSk4=0;QRSk5=0; QRS_f=0; nPB=0; nPE=0; nISO=0; nQ=0; nJ=0; nTB=0; nTX=0; nTE=0; lin_v[0]=0.0;lin_v[1]=0.0;lin_v[2]=0.0; sub_v[0]=0.0; sub_v[1]=0.0;sub_v[2]=0.0; } // data_fin_def::Init void data_fin_def::Insert(data_fin_def value) { index=value.index; HR=value.HR; l0_ST80=value.l0_ST80;l0_ST20=value.l0_ST20; l1_ST80=value.l1_ST80;l1_ST20=value.l1_ST20; l2_ST80=value.l2_ST80;l2_ST20=value.l2_ST20; STk1=value.STk1;STk2=value.STk2;STk3=value.STk3;STk4=value.STk4;STk5=value.STk5; ST_f=value.ST_f; QRSk1=value.QRSk1;QRSk2=value.QRSk2;QRSk3=value.QRSk3;QRSk4=value.QRSk4;QRSk5=value.QRSk5; QRS_f=value.QRS_f; nPB=value.nPB; nPE=value.nPE; nISO=value.nISO; nQ=value.nQ; nJ=value.nJ; nTB=value.nTB; nTX=value.nTX; nTE=value.nTE; } // data_fin_def::Insert void reference_def::copy_ref(reference_def source) { set = source.set; raw_index=source.raw_index; fine_index=source.fine_index; code1= source.code1; code2 =source.code2; lead=source.lead; raw_HR=source.raw_HR; fine_HR=source.fine_HR; raw_ST80=source.raw_ST80; raw_ST20 = source.raw_ST20; fine_ST80 = source.fine_ST80; fine_ST20= source.fine_ST20; STd = source.STd; STsl = source.STsl; ST80=source.ST80; ST_sub=source.ST_sub; nPB = source.nPB; nPE = source.nPE; nISO = source.nISO; nQ = source.nQ ; nJ = source.nJ; nJ80 = source.nJ80; nTB = source.nTB; nTX = source.nTX; nTE = source.nTE; window = source.window ; NL= source.NL; NR = source.NR; NS = source.NS; } // reference_def::copy(reference_def source, dest) void insert_ref(int leadx, reference_def source,int code1x, int code2x) { long i, j; long ref_index; references_index[leadx]++; ref_index=references_index[leadx]; for (i=0; (i < ref_index) && ( references[leadx][i].raw_index < source.raw_index ) ; i++); if ( i < ref_index ) { for (j=ref_index; j > i; j--) references[leadx][j].copy_ref(references[leadx][j-1]);} references[leadx][i].copy_ref(source); references[leadx][i].code1=code1x; references[leadx][i].code2=code2x; reference_act[leadx]=i; } // end insert_ref void button_lead_status_def::copy_button_status( button_lead_status_def source) { Auto_s=source.Auto_s; Subtr_s=source.Subtr_s; OvrApp_s= source.OvrApp_s; ConsLR_s= source.ConsLR_s; Mark = source.Mark; Dmy = source.Dmy; Auto = source.Auto; Subtr = source.Subtr; Cmpt = source.Cmpt; OvrApp = source.OvrApp; OvrLds = source.OvrLds; GlR = source.GlR; SetLB = source.SetLB; SetLE = source.SetLE; DelLI = source.DelLI; Isc = source.Isc; Rate_r = source.Rate_r; Cnd= source.Cnd; AxS = source.AxS; Exm = source.Exm; Atr = source.Atr; Move = source.Move; Del = source.Del; DelA = source.DelA; ChAtr = source.ChAtr; ChAtrA = source.ChAtrA; ConsLR = source.ConsLR; LcRef =source.LcRef; Cancel=source.Cancel; Rpt= source.Rpt; } // end copy_button_status void warning_message(int lines) { xv_set(Sem_0_w_pw.w_m_message1, PANEL_LABEL_STRING,message1, NULL); if ( lines < 2 ) strcpy(message2,""); if ( lines < 3) strcpy(message3, ""); xv_set(Sem_0_w_pw.w_m_message2, PANEL_LABEL_STRING,message2, NULL); xv_set(Sem_0_w_pw.w_m_message3, PANEL_LABEL_STRING,message3, NULL); if (xv_get(Sem_0_w_pw.w_pw, FRAME_CLOSED)) xv_set(Sem_0_w_pw.w_pw, FRAME_CLOSED, FALSE, NULL); xv_set(Sem_0_w_pw.w_pw, FRAME_CMD_PUSHPIN_IN, FALSE, NULL); xv_set(Sem_0_w_pw.w_pw, XV_SHOW, TRUE, NULL); } // end warnig_message long Round(double value) { // Plain vanila round function if(value >= 0.0) return(long(value + 0.5)); else return(long(value - 0.5)); } long TimeToIndex(long time) { return((long)(time * double(FSAMP))); } void TimeToHoursMinSec(long time, long *hou, long *min, long *sec, long *hou_l) { long timeTemp; timeTemp = time; timeTemp = long(timeTemp / 60); timeTemp = timeTemp * 60; *sec = time - timeTemp; time = long(time / 60); timeTemp = time; timeTemp = long(timeTemp / 60); timeTemp = timeTemp * 60; *min = time - timeTemp; time = long(time / 60); *hou_l = time; timeTemp = time; timeTemp = long(timeTemp / 24); timeTemp = timeTemp * 24; *hou = time - timeTemp; } long IndexToTime(long idx) { return(long(double(idx) / FSAMP)); } long Coor_x_l0(long index) { long timex; timex=long(double(index)*1000.0 / FSAMP); return ((long)(160 + double(timex)*960.0 /(double) time_scale_0/1000.0)); } // coor_x_l0 long Coor_y_l0(float value) { return(60-Round(double(value)*20000.0/STAMPL/ampl_0)); // 20000.0 = 20 pix x 1000 uV } // coor_y_l0 long Coor_y_l1(float value) { return(60-Round(double(value)*20000.0/STAMPL/ampl_1)); // 20000.0 = 20 pix x 1000 uV } // coor_y_l1 long Coor_y_l2(float value) { return(60-Round(double(value)*20000.0/STAMPL/ampl_2)); // 20000.0 = 20 pix x 1000 uV } // coor_y_l2 long Coor_x_data(long index) { long timex; timex=long(double(index) * 1000.0 / FSAMP); return ((long)(160 + double(timex)*960.0 /(double) data_scale / 1000.0)); } // coor_x_l0 long Coor_y_data_M(float value) { return(270-Round(double(value)*40000.0/STAMPL/ampl_d)); // 20000.0 = 20 pix x 1000 uV } // coor_y_l0 void reset_global_reference(void) { int l; for (l=0; l < 3; l++ ) { global_ref[l].set=FALSE; global_ref[l].raw_index=0; global_ref[l].fine_index=0; global_ref[l].code1= 0; global_ref[l].code2 =-1; global_ref[l].lead=l; global_ref[l].raw_HR=0; global_ref[l].fine_HR=0; global_ref[l].raw_ST80=0; global_ref[l].raw_ST20 = 0; global_ref[l].fine_ST80 = 0; global_ref[l].fine_ST20= 0; global_ref[l].STd = 0; global_ref[l].STsl = 0; global_ref[l].ST_sub = 0; global_ref[l].nPB = 0; global_ref[l].nPE = 0; global_ref[l].ST80 = 0; global_ref[l].nISO = 0; global_ref[l].nQ =0 ; global_ref[l].nJ = 0; global_ref[l].nJ80 = 0; global_ref[l].nTB = 0; global_ref[l].nTX = 0; global_ref[l].nTE = 0; global_ref[l].window = 0; global_ref[l].NL=0; global_ref[l].NR = 0; global_ref[l].NS = 0; act_ref_data[l].copy_ref(global_ref[l]); references_index[l]=-1; reference_act[l]=-1; loc_interval_b[l].set=FALSE; loc_interval_e[l].set=FALSE; } global_set=FALSE; } // end reset_global_reference float raw_st80(int leadx, long indexx) { float v; switch (leadx) { case 0: v=data_raw[indexx].l0_ST80; break; case 1: v=data_raw[indexx].l1_ST80; break; case 2: v=data_raw[indexx].l2_ST80; break; } // end switch return(v); } // end raw_st80 Bool Is_code(int leadx, long indexx, int cod1, int cod2) { if ( cod1 == 0 && cod2 == 0 && global_ref[0].set && act_reference[leadx].change ) return(TRUE); if ( indexx < 0 ) return(FALSE); return((references[leadx][indexx].code1 == cod1) && (references[leadx][indexx].code2 == cod2)); } // end Is_code void lin_function(int leadx) { long i, r_i, end_i; float val_1, val_2; double fk; long tim_1, tim_2; long first_r, last_r, next_r, GR_index,act_ind; act_ind=reference_act[leadx]; end_i=references_index[leadx]; // temp insert GR insert_ref(leadx,global_ref[leadx],0,0); end_i=end_i+1; GR_index=reference_act[leadx]; first_r=0; while (!Is_code(leadx,first_r,0,0)) first_r++; last_r=end_i; while (!Is_code(leadx,last_r,0,0)) last_r--; next_r=first_r; val_1=raw_st80(leadx,references[leadx][first_r].raw_index); val_2=raw_st80(leadx,references[leadx][first_r].raw_index); tim_1=data_raw[references[leadx][first_r].raw_index].index; tim_2=data_raw[references[leadx][first_r].raw_index].index; fk=0.0; i=0; while ( i <= references[leadx][first_r].raw_index ){ data_raw[i].lin_v[leadx]=val_2; data_raw[i].sub_v[leadx]=raw_st80(leadx,i)- val_2; i++; } // while befor first while ( next_r < last_r ) { val_1=val_2; tim_1=tim_2; next_r++; while (!Is_code(leadx,next_r,0,0)) next_r++; val_2=raw_st80(leadx,references[leadx][next_r].raw_index); tim_2=data_raw[references[leadx][next_r].raw_index].index; fk=(val_2 - val_1) / ( tim_2 - tim_1); while ( i <= references[leadx][next_r].raw_index ){ data_raw[i].lin_v[leadx]=val_1 + fk * (data_raw[i].index - tim_1); data_raw[i].sub_v[leadx]=raw_st80(leadx,i)- data_raw[i].lin_v[leadx]; i++; } // while to next } // while in ref interval while ( i <= raw_last_index ){ data_raw[i].lin_v[leadx]=val_2; data_raw[i].sub_v[leadx]=raw_st80(leadx,i)- val_2; i++; } // while after last set to end data for (r_i=GR_index; r_i < end_i; r_i++) { references[leadx][r_i].copy_ref( references[leadx][r_i+1]); } reference_act[leadx]=act_ind; references_index[leadx]--; } // end lin_function void get_display_code(int leadx, long indexx) { strcpy(ref_code,"??"); switch (references[leadx][indexx].code1){ case -1:if(Is_code(leadx,indexx,-1,1)) strcpy(ref_code,"BI"); if(Is_code(leadx,indexx,-1,7)) strcpy(ref_code,"BR"); if(Is_code(leadx,indexx,-1,11)) strcpy(ref_code,"BO"); break; case -3:if(Is_code(leadx,indexx,-3,1)) strcpy(ref_code,"EI"); if(Is_code(leadx,indexx,-3,7)) strcpy(ref_code,"ER"); if(Is_code(leadx,indexx,-3,11)) strcpy(ref_code,"EO"); break; case 0: if(Is_code(leadx,indexx,0,-1)) strcpy(ref_code,"GR"); if(Is_code(leadx,indexx,0,0)) strcpy(ref_code,"LR"); break; case 2:if(Is_code(leadx,indexx,2,1)) strcpy(ref_code,"XI"); if(Is_code(leadx,indexx,2,7)) strcpy(ref_code,"XR"); if(Is_code(leadx,indexx,2,11)) strcpy(ref_code,"XO"); break; case 4: if(Is_code(leadx,indexx,4,0)) strcpy(ref_code,"DY"); break; case 10:if(Is_code(leadx,indexx,10,0)) strcpy(ref_code,"NO"); break; case 11:if(Is_code(leadx,indexx,11,0)) strcpy(ref_code,"UR"); break; case 12:if(Is_code(leadx,indexx,12,0)) strcpy(ref_code,"PR"); break; case 13:if(Is_code(leadx,indexx,13,0)) strcpy(ref_code,"AX"); break; case 14:if(Is_code(leadx,indexx,14,0)) strcpy(ref_code,"CC"); break; case 15:if(Is_code(leadx,indexx,15,0)) strcpy(ref_code,"UB"); break; case 16:if(Is_code(leadx,indexx,16,0)) strcpy(ref_code,"UE"); break; case 17:if(Is_code(leadx,indexx,17,0)) strcpy(ref_code,"A6"); break; case 18:if(Is_code(leadx,indexx,18,0)) strcpy(ref_code,"A7"); break; } // end code1 // return(ref_code); } // end get_display_code Bool IS_free(int leadx, long indexx, int act_op) { long i; Bool test= TRUE; Bool test_l0=FALSE; Bool test_l1=FALSE; Bool test_l2=FALSE; long code_0, code_1, code_2; char d_c[2]; if ( global_ref[0].set ) { if ( global_ref[0].raw_index == indexx ) { strcpy(message1,"Attempt to overlap Global Reference !"); warning_message(1); return(FALSE); } } switch (leadx ){ case 0: test_l0=TRUE; if (act_op == 2) { test_l1=lead1_data; test_l2=lead2_data; } break; case 1: test_l1=TRUE; if (act_op == 2) { test_l0=TRUE; test_l2=lead2_data; } break; case 2: test_l2=TRUE; if (act_op == 2) { test_l0=TRUE; test_l1=TRUE; } break; } if ( test_l0 ) { test_l0=FALSE; if ( references_index[0] > - 1) { for (i=0; i <= references_index[0]; i++) if ( indexx == references[0][i].raw_index ) { test=FALSE; test_l0=TRUE; code_0=i;} } } // test_l0 if ( test_l1 ) { test_l1=FALSE; if ( references_index[1] > - 1) { for (i=0; i <= references_index[1]; i++) if ( indexx == references[1][i].raw_index ) { test=FALSE; test_l1=TRUE; code_1=i;} } } // test_l1 if ( test_l2 ) { test_l2=FALSE; if ( references_index[2] > - 1) { for (i=0; i <= references_index[2]; i++) if ( indexx == references[2][i].raw_index ) { test=FALSE; test_l2=TRUE; code_2=i;} } } // test_l2 strcpy(message1,""); strcpy(message2,""); strcpy(message3,""); if (test_l0 ) { get_display_code(0,code_0); sprintf(message1,"Lead 0: At %s:", mstimstr(data_raw[indexx].index)); sprintf(message2,"Attempt to overlap existing annotation (%s) !", ref_code); } if (test_l1 ) { get_display_code(1,code_1); sprintf(message1,"Lead 1: At %s:", mstimstr(data_raw[indexx].index)); sprintf(message2,"Attempt to overlap existing annotation (%s) !", ref_code); } if (test_l2 ) { get_display_code(2,code_2); sprintf(message1,"Lead 2: At %s:", mstimstr(data_raw[indexx].index)); sprintf(message2,"Attempt to overlap existing annotation (%s) !", ref_code); } if ( test_l0 OR test_l1 OR test_l2 ) warning_message(3); return(test); } // end IS_free Bool Is_prop_mode(int leadx) { Bool test, t0, t1, t2;; test= ( status_manual_mode && status_unsubtracted && status_manual_mode1 && status_unsubtracted1 && status_manual_mode2 && status_unsubtracted2); t0= status_manual_mode && status_unsubtracted ; t1= status_manual_mode1 && status_unsubtracted1; t2= status_manual_mode2 && status_unsubtracted2; switch (leadx){ case 0: test=test && Lead1_operation == 0 && Lead2_operation == 0; t1= t1 && Lead1_operation == 0; t2= t2 && Lead2_operation == 0; break; case 1: test=test && Lead0_operation == 0 && Lead2_operation == 0; t0= t0 && Lead0_operation == 0; t2= t2 && Lead2_operation == 0; break; case 2: test=test && Lead0_operation == 0 && Lead1_operation == 0; t0= t0 && Lead0_operation == 0; t1= t1 && Lead1_operation == 0; break; } if ( ! test ) { strcpy(message1,""); strcpy(message2,""); strcpy(message3,""); if (! t0 ) sprintf(message1,"Incorrect mode in Lead 0 ! " ); if (! t1 ) sprintf(message2,"Incorrect mode in Lead 1 ! " ); if (! t2 ) sprintf(message3,"Incorrect mode in Lead 2 ! " ); warning_message(3); } return(test); } // end Is_prop_mode float avr_in_avrbeat(int i,int point, int mean_smp) { long iso_off_n; float avr, avr1; // i = lead iso_off_n= 125-point; switch (mean_smp) { case 1: avr1 =A_buff_M[i][iso_off_n]; break; case 3: avr1 = (A_buff_M[i][iso_off_n]+A_buff_M[i][iso_off_n-1]+A_buff_M[i][iso_off_n+1]) / 3.0; break; case 5: avr1 = (A_buff_M[i][iso_off_n]+A_buff_M[i][iso_off_n-1]+A_buff_M[i][iso_off_n+1]+A_buff_M[i][iso_off_n-2]+A_buff_M[i][iso_off_n+2]) / 5.0; break; case 7: avr1 = (A_buff_M[i][iso_off_n]+A_buff_M[i][iso_off_n-1]+A_buff_M[i][iso_off_n+1]+A_buff_M[i][iso_off_n-2]+A_buff_M[i][iso_off_n+2] + A_buff_M[i][iso_off_n-3]+A_buff_M[i][iso_off_n+3]) / 7.0; break; } avr =STAMPL * long(Round(1000.0* avr1/STAMPL))/1000.0; return(avr); } // end avr_in_avrbeat float avr_in_avrbeat_r(int i,int point, int mean_smp) { long iso_off_n; float avr, avr1; iso_off_n= 125-point; switch (mean_smp) { case 1: avr1 =A_buff_R[i][iso_off_n]; break; case 3: avr1 = (A_buff_R[i][iso_off_n]+A_buff_R[i][iso_off_n-1]+A_buff_R[i][iso_off_n+1]) / 3.0; break; case 5: avr1 = (A_buff_R[i][iso_off_n]+A_buff_R[i][iso_off_n-1]+A_buff_R[i][iso_off_n+1]+A_buff_R[i][iso_off_n-2]+A_buff_R[i][iso_off_n+2]) / 5.0; break; case 7: avr1 = (A_buff_R[i][iso_off_n]+A_buff_R[i][iso_off_n-1]+A_buff_R[i][iso_off_n+1]+A_buff_R[i][iso_off_n-2]+A_buff_R[i][iso_off_n+2] + A_buff_R[i][iso_off_n-3]+A_buff_R[i][iso_off_n+3]) / 7.0; break; } avr =STAMPL * long(Round(1000.0* avr1/STAMPL))/1000.0; return(avr); } // end avr_in_avrbeat_r void plot_point_symbol(int s_type, long x, long y) { return; } //end plot_point_symbol int mk_uv(float x_v) { return((long)(Round(1000.0* x_v/STAMPL))); } void write_ref_data_l0(void) { long hours=0,hours_l=0, minutes=0, seconds=0; int lead=0; my_display=l_b_display; my_window=l_b_window; my_gc= gcLead0; XAllocNamedColor(my_display, cmap,"white", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XFillRectangle(my_display, my_window, my_gc, 1,54,130,92); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); if (Marker[lead].set ) { XAllocNamedColor(my_display, cmap,set_color8, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XFillRectangle(my_display, my_window, my_gc, 1,55,130,12); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); sprintf(pr_buff, "RAW: %14s",mstimstr(data_raw[Marker[lead].raw_index].index)); XDrawString(my_display, my_window, my_gc, 2, 66, pr_buff, strlen(pr_buff)); sprintf(pr_buff, "HRate: %9d [bpm]",data_raw[Marker[lead].raw_index].HR); XDrawString(my_display, my_window, my_gc, 2, 78, pr_buff, strlen(pr_buff)); XAllocNamedColor(my_display, cmap,set_color8, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XFillRectangle(my_display, my_window, my_gc, 1,79,130,24); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); sprintf(pr_buff,"ST80:"); XDrawString(my_display, my_window, my_gc, 2, 90, pr_buff, strlen(pr_buff)); if ( reference_act[lead] == -1 && references_index[lead] == -1 ) { sprintf(pr_buff," %6d/%6d",mk_uv(data_raw[Marker[lead].raw_index].l0_ST80), act_ref_data[lead].raw_ST80); // ** } else if (reference_act[lead] > -1 ) { sprintf(pr_buff," %6d/%6d",mk_uv(data_raw[Marker[lead].raw_index].l0_ST80), references[lead][reference_act[lead]].raw_ST80 ); } else { sprintf(pr_buff," %6d/%6s",mk_uv(data_raw[Marker[lead].raw_index].l0_ST80), " "); } XDrawString(my_display, my_window, my_gc, 40, 90, pr_buff, strlen(pr_buff)); sprintf(pr_buff,"STSb:"); XDrawString(my_display, my_window, my_gc, 2, 102, pr_buff, strlen(pr_buff)); if ( reference_act[lead] == -1 && references_index[lead] == -1) { sprintf(pr_buff," %6d/%6d",mk_uv(data_raw[Marker[lead].raw_index].sub_v[lead]), act_ref_data[lead].ST_sub ); } else if (reference_act[lead] > -1 ) { sprintf(pr_buff," %6d/%6d",mk_uv(data_raw[Marker[lead].raw_index].sub_v[lead]), references[lead][reference_act[lead]].ST_sub ); } else { sprintf(pr_buff," %6d/%6s",mk_uv(data_raw[Marker[lead].raw_index].sub_v[lead]), " "); } XDrawString(my_display, my_window, my_gc, 40, 102, pr_buff, strlen(pr_buff)); XAllocNamedColor(my_display, cmap,set_color8, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XFillRectangle(my_display, my_window, my_gc, 1,109,130,12); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); sprintf(pr_buff, "FINE: %14s",mstimstr(data_fin[Marker[lead].fine_index].index)); XDrawString(my_display, my_window, my_gc, 2, 120, pr_buff, strlen(pr_buff)); sprintf(pr_buff, "HRate: %9d [bpm]", data_fin[Marker[lead].fine_index].HR); XDrawString(my_display, my_window, my_gc, 2, 132, pr_buff, strlen(pr_buff)); sprintf(pr_buff,"ST80:"); XDrawString(my_display, my_window, my_gc, 2, 144, pr_buff, strlen(pr_buff)); if ( reference_act[lead] == -1 && references_index[lead] == -1) { sprintf(pr_buff," %6d/%6d", mk_uv( data_fin[Marker[lead].fine_index].l0_ST80), act_ref_data[lead].fine_ST80 ); } else if (reference_act[lead] > -1 ) { sprintf(pr_buff," %6d/%6d", mk_uv( data_fin[Marker[lead].fine_index].l0_ST80), references[lead][reference_act[lead]].fine_ST80 ); } else { sprintf(pr_buff," %6d/%6s",mk_uv(data_fin[Marker[lead].fine_index].l0_ST80), " "); } XDrawString(my_display, my_window, my_gc, 40, 144, pr_buff, strlen(pr_buff)); } XAllocNamedColor(my_display, cmap,set_color8, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XFillRectangle(my_display, my_window, my_gc, 1,13,130,24); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); if ( status_manual_mode ) XDrawString(my_display, my_window, my_gc, 2,24,"MANUAL MODE",11); else XDrawString(my_display, my_window, my_gc, 2,24,"AUTOMATIC MODE",14); if ( status_unsubtracted ) XDrawString(my_display, my_window, my_gc, 2,36,"UNSUBTRACTED",12); else XDrawString(my_display, my_window, my_gc, 2,36,"SUBTRACTED",10); if ( act_reference[0].set ){ if ( act_reference[0].typ == 1 ) sprintf(pr_buff, "ACTIVE: Global Ref"); if ( act_reference[0].typ == 2 ) sprintf(pr_buff, "ACTIVE: Local Ref"); } else { sprintf(pr_buff, "ACTIVE:"); } XDrawString(my_display, my_window, my_gc, 2, 48, pr_buff, strlen(pr_buff)); }// write_ref_data_l0 void write_ref_data_l1(void) { long hours=0,hours_l=0, minutes=0, seconds=0; int lead=1; my_display=l_b1_display; my_window=l_b1_window; my_gc= gcLead1; XAllocNamedColor(my_display, cmap,"white", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XFillRectangle(my_display, my_window, my_gc, 1,54,130,92); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); if (Marker[lead].set ) { XAllocNamedColor(my_display, cmap,set_color8, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XFillRectangle(my_display, my_window, my_gc, 1,55,130,12); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); sprintf(pr_buff, "RAW: %14s",mstimstr(data_raw[Marker[lead].raw_index].index)); XDrawString(my_display, my_window, my_gc, 2, 66, pr_buff, strlen(pr_buff)); sprintf(pr_buff, "HRate: %9d [bpm]",data_raw[Marker[lead].raw_index].HR); XDrawString(my_display, my_window, my_gc, 2, 78, pr_buff, strlen(pr_buff)); XAllocNamedColor(my_display, cmap,set_color8, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XFillRectangle(my_display, my_window, my_gc, 1,79,130,24); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); sprintf(pr_buff,"ST80:"); XDrawString(my_display, my_window, my_gc, 2, 90, pr_buff, strlen(pr_buff)); if ( reference_act[lead] == -1 && references_index[lead] == -1 ) { sprintf(pr_buff," %6d/%6d",mk_uv(data_raw[Marker[lead].raw_index].l1_ST80), act_ref_data[lead].raw_ST80); // ** } else if (reference_act[lead] > -1 ) { sprintf(pr_buff," %6d/%6d",mk_uv(data_raw[Marker[lead].raw_index].l1_ST80), references[lead][reference_act[lead]].raw_ST80 ); } else { sprintf(pr_buff," %6d/%6s",mk_uv(data_raw[Marker[lead].raw_index].l1_ST80), " "); } XDrawString(my_display, my_window, my_gc, 40, 90, pr_buff, strlen(pr_buff)); sprintf(pr_buff,"STSb:"); XDrawString(my_display, my_window, my_gc, 2, 102, pr_buff, strlen(pr_buff)); if ( reference_act[lead] == -1 && references_index[lead] == -1) { sprintf(pr_buff," %6d/%6d",mk_uv(data_raw[Marker[lead].raw_index].sub_v[lead]), act_ref_data[lead].ST_sub ); // ** } else if (reference_act[lead] > -1 ) { sprintf(pr_buff," %6d/%6d",mk_uv(data_raw[Marker[lead].raw_index].sub_v[lead]), references[lead][reference_act[lead]].ST_sub ); } else { sprintf(pr_buff," %6d/%6s",mk_uv(data_raw[Marker[lead].raw_index].sub_v[lead]), " "); } XDrawString(my_display, my_window, my_gc, 40, 102, pr_buff, strlen(pr_buff)); XAllocNamedColor(my_display, cmap,set_color8, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XFillRectangle(my_display, my_window, my_gc, 1,109,130,12); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); sprintf(pr_buff, "FINE: %14s",mstimstr(data_fin[Marker[lead].fine_index].index)); XDrawString(my_display, my_window, my_gc, 2, 120, pr_buff, strlen(pr_buff)); sprintf(pr_buff, "HRate: %9d [bpm]", data_fin[Marker[lead].fine_index].HR); XDrawString(my_display, my_window, my_gc, 2, 132, pr_buff, strlen(pr_buff)); sprintf(pr_buff,"ST80:"); XDrawString(my_display, my_window, my_gc, 2, 144, pr_buff, strlen(pr_buff)); if ( reference_act[lead] == -1 && references_index[lead] == -1) { sprintf(pr_buff," %6d/%6d", mk_uv( data_fin[Marker[lead].fine_index].l1_ST80), act_ref_data[lead].fine_ST80 ); // ** } else if (reference_act[lead] > -1 ) { sprintf(pr_buff," %6d/%6d", mk_uv( data_fin[Marker[lead].fine_index].l1_ST80), references[lead][reference_act[lead]].fine_ST80 ); } else { sprintf(pr_buff," %6d/%6s",mk_uv(data_fin[Marker[lead].fine_index].l1_ST80), " "); } XDrawString(my_display, my_window, my_gc, 40, 144, pr_buff, strlen(pr_buff)); } XAllocNamedColor(my_display, cmap,set_color8, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XFillRectangle(my_display, my_window, my_gc, 1,13,130,24); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); if ( status_manual_mode1 ) XDrawString(my_display, my_window, my_gc, 2,24,"MANUAL MODE",11); else XDrawString(my_display, my_window, my_gc, 2,24,"AUTOMATIC MODE",14); if ( status_unsubtracted1 ) XDrawString(my_display, my_window, my_gc, 2,36,"UNSUBTRACTED",12); else XDrawString(my_display, my_window, my_gc, 2,36,"SUBTRACTED",10); if ( act_reference[1].set ){ if ( act_reference[1].typ == 1 ) sprintf(pr_buff, "ACTIVE: Global Ref"); if ( act_reference[1].typ == 2 ) sprintf(pr_buff, "ACTIVE: Local Ref"); } else { sprintf(pr_buff, "ACTIVE:"); } XDrawString(my_display, my_window, my_gc, 2, 48, pr_buff, strlen(pr_buff)); }// write_ref_data_l1 void write_ref_data_l2(void) { long hours=0,hours_l=0, minutes=0, seconds=0; int lead=2; my_display=l_b2_display; my_window=l_b2_window; my_gc= gcLead2; XAllocNamedColor(my_display, cmap,"white", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XFillRectangle(my_display, my_window, my_gc, 1,54,130,92); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); if (Marker[lead].set ) { XAllocNamedColor(my_display, cmap,set_color8, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XFillRectangle(my_display, my_window, my_gc, 1,55,130,12); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); sprintf(pr_buff, "RAW: %14s",mstimstr(data_raw[Marker[lead].raw_index].index)); XDrawString(my_display, my_window, my_gc, 2, 66, pr_buff, strlen(pr_buff)); sprintf(pr_buff, "HRate: %9d [bpm]",data_raw[Marker[lead].raw_index].HR); XDrawString(my_display, my_window, my_gc, 2, 78, pr_buff, strlen(pr_buff)); XAllocNamedColor(my_display, cmap,set_color8, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XFillRectangle(my_display, my_window, my_gc, 1,79,130,24); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); sprintf(pr_buff,"ST80:"); XDrawString(my_display, my_window, my_gc, 2, 90, pr_buff, strlen(pr_buff)); if ( reference_act[lead] == -1 && references_index[lead] == -1 ) { sprintf(pr_buff," %6d/%6d",mk_uv(data_raw[Marker[lead].raw_index].l2_ST80), act_ref_data[lead].raw_ST80); // ** } else if (reference_act[lead] > -1 ) { sprintf(pr_buff," %6d/%6d",mk_uv(data_raw[Marker[lead].raw_index].l2_ST80), references[lead][reference_act[lead]].raw_ST80 ); } else { sprintf(pr_buff," %6d/%6s",mk_uv(data_raw[Marker[lead].raw_index].l2_ST80), " "); } XDrawString(my_display, my_window, my_gc, 40, 90, pr_buff, strlen(pr_buff)); sprintf(pr_buff,"STSb:"); XDrawString(my_display, my_window, my_gc, 2, 102, pr_buff, strlen(pr_buff)); if ( reference_act[lead] == -1 && references_index[lead] == -1) { sprintf(pr_buff," %6d/%6d",mk_uv(data_raw[Marker[lead].raw_index].sub_v[lead]), act_ref_data[lead].ST_sub ); // ** } else if (reference_act[lead] > -1 ) { sprintf(pr_buff," %6d/%6d",mk_uv(data_raw[Marker[lead].raw_index].sub_v[lead]), references[lead][reference_act[lead]].ST_sub ); } else { sprintf(pr_buff," %6d/%6s",mk_uv(data_raw[Marker[lead].raw_index].sub_v[lead]), " "); } XDrawString(my_display, my_window, my_gc, 40, 102, pr_buff, strlen(pr_buff)); XAllocNamedColor(my_display, cmap,set_color8, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XFillRectangle(my_display, my_window, my_gc, 1,109,130,12); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); sprintf(pr_buff, "FINE: %14s",mstimstr(data_fin[Marker[lead].fine_index].index)); XDrawString(my_display, my_window, my_gc, 2, 120, pr_buff, strlen(pr_buff)); sprintf(pr_buff, "HRate: %9d [bpm]", data_fin[Marker[lead].fine_index].HR); XDrawString(my_display, my_window, my_gc, 2, 132, pr_buff, strlen(pr_buff)); sprintf(pr_buff,"ST80:"); XDrawString(my_display, my_window, my_gc, 2, 144, pr_buff, strlen(pr_buff)); if ( reference_act[lead] == -1 && references_index[lead] == -1) { sprintf(pr_buff," %6d/%6d", mk_uv( data_fin[Marker[lead].fine_index].l2_ST80), act_ref_data[lead].fine_ST80 ); // ** } else if (reference_act[lead] > -1 ) { sprintf(pr_buff," %6d/%6d", mk_uv( data_fin[Marker[lead].fine_index].l2_ST80), references[lead][reference_act[lead]].fine_ST80 ); } else { sprintf(pr_buff," %6d/%6s",mk_uv(data_fin[Marker[lead].fine_index].l2_ST80), " "); } XDrawString(my_display, my_window, my_gc, 40, 144, pr_buff, strlen(pr_buff)); } XAllocNamedColor(my_display, cmap,set_color8, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XFillRectangle(my_display, my_window, my_gc, 1,13,130,24); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); if ( status_manual_mode2 ) XDrawString(my_display, my_window, my_gc, 2,24,"MANUAL MODE",11); else XDrawString(my_display, my_window, my_gc, 2,24,"AUTOMATIC MODE",14); if ( status_unsubtracted2 ) XDrawString(my_display, my_window, my_gc, 2,36,"UNSUBTRACTED",12); else XDrawString(my_display, my_window, my_gc, 2,36,"SUBTRACTED",10); if ( act_reference[2].set ){ if ( act_reference[2].typ == 1 ) sprintf(pr_buff, "ACTIVE: Global Ref"); if ( act_reference[2].typ == 2 ) sprintf(pr_buff, "ACTIVE: Local Ref"); } else { sprintf(pr_buff, "ACTIVE:"); } XDrawString(my_display, my_window, my_gc, 2, 48, pr_buff, strlen(pr_buff)); }// write_ref_data_l2 void draw_lead0_A(void) { long i, begmisx, begmise, j, ischonbegx, ischonbege; long x_0, x_1, x_x, y_0, y_1, y1_0, y1_1; Bool act_loc; // episodes Bool pl_epi=FALSE, pl_epii=FALSE; Bool epi_error=FALSE, epi_error_first=TRUE; long ep_index=0; int ep_status_i=0, ep_status_r=0, ep_status_o=0; index_0_b=TimeToIndex(diagram_time_begin_lead); index_0_e=TimeToIndex(diagram_time_begin_lead+time_scale_0); index_0=index_0_b; XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); if ( ovr0_l1 ) { XAllocNamedColor(my_display, cmap,set_color5, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); i=0; while (data_raw[i].index < index_0_b) i++; x_0=Coor_x_l0(data_raw[i].index-index_0_b); y_0=Coor_y_l0(data_raw[i].l1_ST80); while ( (data_raw[i].index < index_0_e ) && ( i < raw_last_index) ){ i++; x_1=Coor_x_l0(data_raw[i].index-index_0_b); y_1=Coor_y_l0(data_raw[i].l1_ST80); if ((x_1 > x_0 ) OR PLOT_ALL ) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); x_0=x_1; y_0=y_1; } } // end while XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } if ( ovr0_l2 ) { XAllocNamedColor(my_display, cmap,set_color6, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); i=0; while (data_raw[i].index < index_0_b) i++; x_0=Coor_x_l0(data_raw[i].index-index_0_b); y_0=Coor_y_l0(data_raw[i].l2_ST80); while ( (data_raw[i].index < index_0_e ) && ( i < raw_last_index) ){ i++; x_1=Coor_x_l0(data_raw[i].index-index_0_b); y_1=Coor_y_l0(data_raw[i].l2_ST80); if ((x_1 > x_0 ) OR PLOT_ALL ) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); x_0=x_1; y_0=y_1; } } // end while XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } if ( ovr0_app ) { XAllocNamedColor(my_display, cmap,set_color3, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); i=0; while (data_raw[i].index < index_0_b) i++; x_0=Coor_x_l0(data_raw[i].index-index_0_b); y_0=Coor_y_l0(data_raw[i].lin_v[0]); while ( (data_raw[i].index < index_0_e ) && ( i < raw_last_index) ){ i++; x_1=Coor_x_l0(data_raw[i].index-index_0_b); y_1=Coor_y_l0(data_raw[i].lin_v[0]); if ((x_1 > x_0 ) OR PLOT_ALL ) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); x_0=x_1; y_0=y_1; } } // end while XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } index_0_b=TimeToIndex(diagram_time_begin_lead); index_0_e=TimeToIndex(diagram_time_begin_lead+time_scale_0); index_0=index_0_b; XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); i=0; while (data_raw[i].index < index_0_b) i++; raw_display_begin=i; fin_display_begin=i; x_0=Coor_x_l0(data_raw[i].index-index_0_b); if (status_unsubtracted ) {y_0=Coor_y_l0(data_raw[i].l0_ST80);} else {y_0=Coor_y_l0(data_raw[i].sub_v[0]);} if (lead0_plot_button_status.HRRaw ) { y1_0=170-data_raw[i].HR/2; XDrawString(my_display, my_window, my_gc, 2,161, "Heart Rate Raw [bpm]",20);} if (lead0_plot_button_status.STslRaw ) { y1_0=60+Coor_y_l0(data_raw[i].l0_ST80-data_raw[i].l0_ST20); XDrawString(my_display, my_window, my_gc, 2,161, "ST Slope Raw [uV]",17);} if ((lead0_plot_button_status.Episodes ) && (references_index[0] >= 0)) { XDrawString(my_display, my_window, my_gc, 2,161, "Episodes",8);} begmisx = -1; begmise = -1; ischonbegx = -1; ischonbege = -1; while ( (data_raw[i].index < index_0_e ) && ( i < raw_last_index) ) { if ((lead0_plot_button_status.Episodes ) && (references_index[0] >= 0)) { while (( references[0][ep_index].raw_index <= i ) && ( ep_index <= references_index[0] )){ if (Is_code(0,ep_index,-1,1)){ if ( (ep_status_i == 0 ) && (ep_status_r == 0) && (ep_status_o == 0) ) { ep_status_i=1; pl_epi=TRUE; pl_epii=TRUE;} else { epi_error = TRUE; pl_epi=FALSE; pl_epii=FALSE; } } if (Is_code(0,ep_index,2,1)){ if (( ep_status_i == 1 ) && (ep_status_r == 0) && (ep_status_o == 0)) { ep_status_i=2; pl_epi=TRUE; pl_epii=TRUE;} else { if (ep_status_i == 0) begmisx = i; ischonbegx = i; epi_error = TRUE; pl_epi=FALSE; pl_epii=FALSE;} } if (Is_code(0,ep_index,-3,1)){ if (( ep_status_i == 2 ) && (ep_status_r == 0) && (ep_status_o == 0)) { ep_status_i=0; pl_epi=FALSE; pl_epii=FALSE;} else { if (ep_status_i == 0) begmise = i; ischonbege = i; epi_error = TRUE; pl_epi=FALSE; pl_epii=FALSE;} } if (Is_code(0,ep_index,-1,7)){ if (( ep_status_r == 0 ) && (ep_status_i == 0) && (ep_status_o == 0)) { ep_status_r=1; pl_epi=TRUE;} else { epi_error = TRUE; pl_epi=FALSE; } } if (Is_code(0,ep_index,2,7)){ if (( ep_status_r == 1 ) && (ep_status_i == 0) && (ep_status_o == 0)) { ep_status_r=2; pl_epi=TRUE;} else { if (ep_status_r == 0) begmisx = i; epi_error = TRUE; pl_epi=FALSE; } } if (Is_code(0,ep_index,-3,7)){ if (( ep_status_r == 2 ) && (ep_status_i == 0) && (ep_status_o == 0)) { ep_status_r=0; pl_epi=FALSE;} else { if (ep_status_r == 0) begmise = i; epi_error = TRUE; pl_epi=FALSE; } } if (Is_code(0,ep_index,-1,11)){ if (( ep_status_o == 0 ) && (ep_status_r == 0) && (ep_status_i == 0)) { ep_status_o=1; pl_epi=TRUE;} else { epi_error = TRUE; pl_epi=FALSE; } } if (Is_code(0,ep_index,2,11)){ if (( ep_status_o == 1 ) && (ep_status_r == 0) && (ep_status_i == 0)) { ep_status_o=2; pl_epi=TRUE;} else { if (ep_status_o == 0) begmisx = i; epi_error = TRUE; pl_epi=FALSE; } } if (Is_code(0,ep_index,-3,11)){ if (( ep_status_o == 2 ) && (ep_status_r == 0) && (ep_status_i == 0)) { ep_status_o=0; pl_epi=FALSE;} else { if (ep_status_o == 0) begmise = i; epi_error = TRUE; pl_epi=FALSE; } } if ( epi_error) sprintf(message2, "Time: %14s",mstimstr(data_raw[references[0][ep_index].raw_index].index)); ep_index++; if ((ep_index > references_index[0] ) && ((ep_status_i != 0) || (ep_status_r != 0) || (ep_status_o != 0)) ) { epi_error=TRUE; sprintf(message2, "Time: %14s",mstimstr(data_raw[references[0][references_index[0]].raw_index].index)); } if ( epi_error && epi_error_first ) { strcpy(message1,"Lead 0: Inconsistent episode !"); // // warning_message(2); // epi_error=FALSE; ep_status_i=0; ep_status_r=0; ep_status_o=0; epi_error_first=FALSE; } } if (pl_epi) { XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XDrawLine(my_display, my_window, my_gc, x_0,116, x_0,120); // XDrawLine(my_display, my_window, my_gc, x_0,146, x_0,150); XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); // pl_epi=ep_status != 0; } // if (pl_epii) { // XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); // XDrawLine(my_display, my_window, my_gc, x_0,136, x_0,140); // XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); // // pl_epi=ep_status != 0; // } } // end episodes i++; x_1=Coor_x_l0(data_raw[i].index-index_0_b); if (status_unsubtracted ) {y_1=Coor_y_l0(data_raw[i].l0_ST80);} else {y_1=Coor_y_l0(data_raw[i].sub_v[0]);} if ((x_1 > x_0 ) OR PLOT_ALL ) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XDrawLine(my_display, my_window, my_gc, x_0,156, x_0,160); XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); if (lead0_plot_button_status.HRRaw ){ y1_1=170-data_raw[i].HR/2; XDrawLine(my_display, my_window, my_gc, x_0,y1_0, x_1,y1_1); y1_0=y1_1; } if (lead0_plot_button_status.STslRaw ){ y1_1=60+Coor_y_l0(data_raw[i].l0_ST80-data_raw[i].l0_ST20); XDrawLine(my_display, my_window, my_gc, x_0,y1_0, x_1,y1_1); y1_0=y1_1; } x_0=x_1; y_0=y_1; } } // end while XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XDrawLine(my_display, my_window, my_gc, x_0,156, x_0,160); XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); if (begmisx != -1 && begmise != -1) { j=begmise; begmisx = begmise = -1; x_x=Coor_x_l0(data_raw[j].index-index_0_b); while ( (data_raw[j].index >= index_0_b ) && ( j >= 0) ) { XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XDrawLine(my_display, my_window, my_gc, x_x,116, x_x,120); // XDrawLine(my_display, my_window, my_gc, x_x,146, x_x,150); XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); j--; x_x=Coor_x_l0(data_raw[j].index-index_0_b); } } // if (ischonbegx != -1 && ischonbege != -1) { // j=ischonbegx; ischonbegx = ischonbege = -1; // x_x=Coor_x_l0(data_raw[j].index-index_0_b); // while ( (data_raw[j].index >= index_0_b ) && ( j >= 0) ) { // XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); // XDrawLine(my_display, my_window, my_gc, x_x,136, x_x,140); // XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); // j--; // x_x=Coor_x_l0(data_raw[j].index-index_0_b); // } // } raw_display_end=i-1; fin_display_end=raw_display_end; while ( (data_fin[fin_display_end].index < index_0_e) && ( fin_display_end < fin_last_index) ) fin_display_end++; fin_display_end=fin_display_end-1; i=0; while (data_fin[i].index < index_0_b) i++; fin_display_begin=i; if (lead0_plot_button_status.HRate OR lead0_plot_button_status.STFine OR lead0_plot_button_status.STslFine OR lead0_plot_button_status.ISOJ ){ x_0=Coor_x_l0(data_fin[i].index-index_0_b); if (lead0_plot_button_status.HRate ) { y_0=170-data_fin[i].HR/2; XDrawString(my_display, my_window, my_gc, 2,161, "Heart Rate [bpm]",16);} if (lead0_plot_button_status.STFine ) { y_0=60+Coor_y_l0(data_fin[i].l0_ST80); XDrawString(my_display, my_window, my_gc, 2,161, "ST Fine [uV]",12);} if (lead0_plot_button_status.STslFine ) { y_0=60+Coor_y_l0(data_fin[i].l0_ST80-data_fin[i].l0_ST20); XDrawString(my_display, my_window, my_gc, 2,161, "ST Slope Fine [uV]",18);} if (lead0_plot_button_status.ISOJ ) { y_0=(long)(160-1000.0*(data_fin[i].nISO +data_fin[i].nJ)/FSAMP/3); XDrawString(my_display, my_window, my_gc, 2,161, "ISO - J [ms]",12);} while ( (data_fin[i].index < index_0_e) && ( i < fin_last_index) ) { i++; x_1=Coor_x_l0(data_fin[i].index-index_0_b); if (lead0_plot_button_status.HRate ) y_1=170-data_fin[i].HR/2; if (lead0_plot_button_status.STFine ) y_1=60+Coor_y_l0(data_fin[i].l0_ST80); if (lead0_plot_button_status.STslFine ) y_1=60+Coor_y_l0(data_fin[i].l0_ST80-data_fin[i].l0_ST20); if (lead0_plot_button_status.ISOJ ) y_1=(long)(160-1000.0*(data_fin[i].nISO +data_fin[i].nJ)/FSAMP/3); if ((x_1 > x_0 ) OR PLOT_ALL ) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XDrawLine(my_display, my_window, my_gc, x_0,160, x_0,163); XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); x_0=x_1; y_0=y_1; } } // end while XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XDrawLine(my_display, my_window, my_gc, x_0,160, x_0,163); XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); fin_display_end=i-1; } // if hrate if ( references_index[0] >= 0 ){ for (i=0; i <= references_index[0]; i++){ if ( (data_raw[references[0][i].raw_index].index >= index_0_b) && (data_raw[references[0][i].raw_index].index <= index_0_e) ) { act_loc=FALSE; if ( Is_code(0,i,0,0) ){ act_loc= act_reference[0].set && ( act_reference[0].typ == 2 ) && (act_reference[0].index == i); if (( i == reference_act[0] ) OR act_loc ) { XAllocNamedColor(my_display, cmap,set_color1, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } x_0=Coor_x_l0(data_raw[references[0][i].raw_index].index-index_0_b); XDrawLine(my_display, my_window, my_gc, x_0,10, x_0,160); XDrawString(my_display, my_window, my_gc, x_0 - 10 ,10, "LR",2); if (( i == reference_act[0] ) OR act_loc ) { XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } } else // other ref { if ( i == reference_act[0] ) { XAllocNamedColor(my_display, cmap,set_color2, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } x_0=Coor_x_l0(data_raw[references[0][i].raw_index].index-index_0_b); XDrawLine(my_display, my_window, my_gc, x_0,10, x_0,160); get_display_code(0,i); XDrawString(my_display, my_window, my_gc, x_0 - 10 ,10, ref_code,2); if ( i == reference_act[0] ) { XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } } } } // end for } // plot ref. if ( loc_interval_b[0].set && (data_raw[loc_interval_b[0].raw_index].index >= index_0_b) && (data_raw[loc_interval_b[0].raw_index].index <= index_0_e) ) { x_0=Coor_x_l0(data_raw[loc_interval_b[0].raw_index].index-index_0_b); XAllocNamedColor(my_display, cmap,set_color3, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XDrawLine(my_display, my_window, my_gc, x_0,10, x_0,160); XDrawString(my_display, my_window, my_gc, x_0 - 9 ,20, "B",1); } if ( loc_interval_e[0].set && (data_raw[loc_interval_e[0].raw_index].index >= index_0_b) && (data_raw[loc_interval_e[0].raw_index].index <= index_0_e) ) { x_0=Coor_x_l0(data_raw[loc_interval_e[0].raw_index].index-index_0_b); XAllocNamedColor(my_display, cmap,set_color3, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XDrawLine(my_display, my_window, my_gc, x_0,10, x_0,160); XDrawString(my_display, my_window, my_gc, x_0 - 9 ,20, "E",1); } if ( global_set && (data_raw[global_ref[0].raw_index].index >= index_0_b) && (data_raw[global_ref[0].raw_index].index <= index_0_e) ) { XAllocNamedColor(my_display, cmap,set_color1, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); x_0=Coor_x_l0(data_raw[global_ref[0].raw_index].index-index_0_b); XDrawLine(my_display, my_window, my_gc, x_0,10, x_0,160); XDrawString(my_display, my_window, my_gc, x_0 - 10 ,10, "GR",2); } if ( Marker[0].set && (data_raw[Marker[0].raw_index].index >= index_0_b) && (data_raw[Marker[0].raw_index].index <= index_0_e) ) { XAllocNamedColor(my_display, cmap,set_color3, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); x_0=Coor_x_l0(data_raw[Marker[0].raw_index].index-index_0_b); XDrawLine(my_display, my_window, my_gc, x_0,10, x_0,160); XDrawString(my_display, my_window, my_gc, x_0 - 11 ,20, "M",1); x_1=Coor_x_l0(data_fin[Marker[0].fine_index].index-index_0_b); if ( x_1 == x_0) x_1++; XDrawLine(my_display, my_window, my_gc, x_1,80, x_1,160); } // end marker XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } // end draw_lead0_A(void) void draw_lead1_A(void) { long i, begmisx, begmise, j, ischonbegx, ischonbege; long x_0, x_1, x_x, y_0, y_1, y1_0,y1_1; Bool act_loc; Bool pl_epi=FALSE, pl_epii=FALSE; Bool epi_error=FALSE, epi_error_first=TRUE; long ep_index=0; int ep_status_i=0, ep_status_r=0, ep_status_o=0; index_0_b=TimeToIndex(diagram_time_begin_lead); index_0_e=TimeToIndex(diagram_time_begin_lead+time_scale_0); index_0=index_0_b; XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); if ( ovr1_l0 ) { XAllocNamedColor(my_display, cmap,set_color4, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); i=0; while (data_raw[i].index < index_0_b) i++; x_0=Coor_x_l0(data_raw[i].index-index_0_b); y_0=Coor_y_l1(data_raw[i].l0_ST80); while ( (data_raw[i].index < index_0_e ) && ( i < raw_last_index) ){ i++; x_1=Coor_x_l0(data_raw[i].index-index_0_b); y_1=Coor_y_l1(data_raw[i].l0_ST80); if ((x_1 > x_0 ) OR PLOT_ALL ) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); x_0=x_1; y_0=y_1; } } // end while XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } if ( ovr1_l2 ) { XAllocNamedColor(my_display, cmap,set_color6, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); i=0; while (data_raw[i].index < index_0_b) i++; x_0=Coor_x_l0(data_raw[i].index-index_0_b); y_0=Coor_y_l1(data_raw[i].l2_ST80); while ( (data_raw[i].index < index_0_e ) && ( i < raw_last_index) ){ i++; x_1=Coor_x_l0(data_raw[i].index-index_0_b); y_1=Coor_y_l1(data_raw[i].l2_ST80); if ((x_1 > x_0 ) OR PLOT_ALL ) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); x_0=x_1; y_0=y_1; } } // end while XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } if ( ovr1_app ) { XAllocNamedColor(my_display, cmap,set_color3, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); i=0; while (data_raw[i].index < index_0_b) i++; x_0=Coor_x_l0(data_raw[i].index-index_0_b); y_0=Coor_y_l1(data_raw[i].lin_v[1]); while ( (data_raw[i].index < index_0_e ) && ( i < raw_last_index) ){ i++; x_1=Coor_x_l0(data_raw[i].index-index_0_b); y_1=Coor_y_l1(data_raw[i].lin_v[1]); if ((x_1 > x_0 ) OR PLOT_ALL ) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); x_0=x_1; y_0=y_1; } } // end while XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); i=0; while (data_raw[i].index < index_0_b) i++; raw_display_begin=i; x_0=Coor_x_l0(data_raw[i].index-index_0_b); if (status_unsubtracted1 ) {y_0=Coor_y_l1(data_raw[i].l1_ST80);} else {y_0=Coor_y_l1(data_raw[i].sub_v[1]);} if (lead1_plot_button_status.HRRaw ) { y1_0=170-data_raw[i].HR/2; XDrawString(my_display, my_window, my_gc, 2,161, "Heart Rate Raw [bpm]",20);} if (lead1_plot_button_status.STslRaw ) { y1_0=60+Coor_y_l1(data_raw[i].l1_ST80-data_raw[i].l1_ST20); XDrawString(my_display, my_window, my_gc, 2,161, "ST Slope Raw [uV]",17);} if ((lead1_plot_button_status.Episodes ) && (references_index[1] >= 0)) { XDrawString(my_display, my_window, my_gc, 2,161, "Episodes",8);} begmisx = -1; begmise = -1; ischonbegx = -1; ischonbege = -1; while ( (data_raw[i].index < index_0_e ) && ( i < raw_last_index) ){ if ((lead1_plot_button_status.Episodes ) && (references_index[1] >= 0)) { while (( references[1][ep_index].raw_index <= i ) && ( ep_index <= references_index[1] )){ if (Is_code(1,ep_index,-1,1)){ if ( (ep_status_i == 0 ) && (ep_status_r == 0) && (ep_status_o == 0) ) { ep_status_i=1; pl_epi=TRUE; pl_epii=TRUE;} else { epi_error = TRUE; pl_epi=FALSE; pl_epii=FALSE; } } if (Is_code(1,ep_index,2,1)){ if (( ep_status_i == 1 ) && (ep_status_r == 0) && (ep_status_o == 0)) { ep_status_i=2; pl_epi=TRUE; pl_epii=TRUE;} else { if (ep_status_i == 0) begmisx = i; ischonbegx = i; epi_error = TRUE; pl_epi=FALSE; pl_epii=FALSE;} } if (Is_code(1,ep_index,-3,1)){ if (( ep_status_i == 2 ) && (ep_status_r == 0) && (ep_status_o == 0)) { ep_status_i=0; pl_epi=FALSE; pl_epii=FALSE;} else { if (ep_status_i == 0) begmise = i; ischonbege = i; epi_error = TRUE; pl_epi=FALSE; pl_epii=FALSE;} } if (Is_code(1,ep_index,-1,7)){ if (( ep_status_r == 0 ) && (ep_status_i == 0) && (ep_status_o == 0)) { ep_status_r=1; pl_epi=TRUE;} else { epi_error = TRUE; pl_epi=FALSE; } } if (Is_code(1,ep_index,2,7)){ if (( ep_status_r == 1 ) && (ep_status_i == 0) && (ep_status_o == 0)) { ep_status_r=2; pl_epi=TRUE;} else { if (ep_status_r == 0) begmisx = i; epi_error = TRUE; pl_epi=FALSE; } } if (Is_code(1,ep_index,-3,7)){ if (( ep_status_r == 2 ) && (ep_status_i == 0) && (ep_status_o == 0)) { ep_status_r=0; pl_epi=FALSE;} else { if (ep_status_r == 0) begmise = i; epi_error = TRUE; pl_epi=FALSE; } } if (Is_code(1,ep_index,-1,11)){ if (( ep_status_o == 0 ) && (ep_status_r == 0) && (ep_status_i == 0)) { ep_status_o=1; pl_epi=TRUE;} else { epi_error = TRUE; pl_epi=FALSE; } } if (Is_code(1,ep_index,2,11)){ if (( ep_status_o == 1 ) && (ep_status_r == 0) && (ep_status_i == 0)) { ep_status_o=2; pl_epi=TRUE;} else { if (ep_status_o == 0) begmisx = i; epi_error = TRUE; pl_epi=FALSE; } } if (Is_code(1,ep_index,-3,11)){ if (( ep_status_o == 2 ) && (ep_status_r == 0) && (ep_status_i == 0)) { ep_status_o=0; pl_epi=FALSE;} else { if (ep_status_o == 0) begmise = i; epi_error = TRUE; pl_epi=FALSE; } } if ( epi_error) sprintf(message2, "Time: %14s",mstimstr(data_raw[references[1][ep_index].raw_index].index)); ep_index++; if ((ep_index > references_index[1] ) && ((ep_status_i != 0) || (ep_status_r != 0) || (ep_status_o != 0)) ) { epi_error=TRUE; sprintf(message2, "Time: %14s",mstimstr(data_raw[references[1][references_index[1]].raw_index].index)); } if ( epi_error && epi_error_first ) { strcpy(message1,"Lead 1: Inconsistent episode !"); // // warning_message(2); // epi_error=FALSE; ep_status_i=0; ep_status_r=0; ep_status_o=0; epi_error_first=FALSE; } } if (pl_epi) { XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XDrawLine(my_display, my_window, my_gc, x_0,116, x_0,120); // XDrawLine(my_display, my_window, my_gc, x_0,146, x_0,150); XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); // pl_epi=ep_status != 0; } // if (pl_epii) { // XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); // XDrawLine(my_display, my_window, my_gc, x_0,136, x_0,140); // XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); // // pl_epi=ep_status != 0; // } } // end episodes i++; x_1=Coor_x_l0(data_raw[i].index-index_0_b); if (status_unsubtracted1) {y_1=Coor_y_l1(data_raw[i].l1_ST80);} else {y_1=Coor_y_l1(data_raw[i].sub_v[1]);} if ((x_1 > x_0 ) OR PLOT_ALL ) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XDrawLine(my_display, my_window, my_gc, x_0,156, x_0,160); XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); if (lead1_plot_button_status.HRRaw ){ y1_1=170-data_raw[i].HR/2; XDrawLine(my_display, my_window, my_gc, x_0,y1_0, x_1,y1_1); y1_0=y1_1; } if (lead1_plot_button_status.STslRaw ){ y1_1=60+Coor_y_l1(data_raw[i].l1_ST80-data_raw[i].l1_ST20); XDrawLine(my_display, my_window, my_gc, x_0,y1_0, x_1,y1_1); y1_0=y1_1; } x_0=x_1; y_0=y_1; } } // end while XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XDrawLine(my_display, my_window, my_gc, x_0,156, x_0,160); XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); if (begmisx != -1 && begmise != -1) { j=begmise; begmisx = begmise = -1; x_x=Coor_x_l0(data_raw[j].index-index_0_b); while ( (data_raw[j].index >= index_0_b ) && ( j >= 0) ) { XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XDrawLine(my_display, my_window, my_gc, x_x,116, x_x,120); // XDrawLine(my_display, my_window, my_gc, x_x,146, x_x,150); XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); j--; x_x=Coor_x_l0(data_raw[j].index-index_0_b); } } // if (ischonbegx != -1 && ischonbege != -1) { // j=ischonbegx; ischonbegx = ischonbege = -1; // x_x=Coor_x_l0(data_raw[j].index-index_0_b); // while ( (data_raw[j].index >= index_0_b ) && ( j >= 0) ) { // XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); // XDrawLine(my_display, my_window, my_gc, x_x,136, x_x,140); // XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); // j--; // x_x=Coor_x_l0(data_raw[j].index-index_0_b); // } // } raw_display_end=i-1; fin_display_end=raw_display_end; while ( (data_fin[fin_display_end].index < index_0_e) && ( fin_display_end < fin_last_index) ) fin_display_end++; fin_display_end=fin_display_end-1; i=0; while (data_fin[i].index < index_0_b) i++; fin_display_begin=i; if (lead1_plot_button_status.HRate OR lead1_plot_button_status.STFine OR lead1_plot_button_status.STslFine OR lead1_plot_button_status.ISOJ ){ x_0=Coor_x_l0(data_fin[i].index-index_0_b); if (lead1_plot_button_status.HRate ) { y_0=170-data_fin[i].HR/2; XDrawString(my_display, my_window, my_gc, 2,161, "Heart Rate [bpm]",16);} if (lead1_plot_button_status.STFine ) { y_0=60+Coor_y_l1(data_fin[i].l1_ST80); XDrawString(my_display, my_window, my_gc, 2,161, "ST Fine [uV]",12);} if (lead1_plot_button_status.STslFine ) { y_0=60+Coor_y_l1(data_fin[i].l1_ST80-data_fin[i].l1_ST20); XDrawString(my_display, my_window, my_gc, 2,161, "ST Slope Fine [uV]",18);} if (lead1_plot_button_status.ISOJ ) { y_0=(long)(160-1000.0*(data_fin[i].nISO +data_fin[i].nJ)/FSAMP/3); XDrawString(my_display, my_window, my_gc, 2,161, "ISO - J [ms]",12);} while ( (data_fin[i].index < index_0_e) && ( i < fin_last_index) ) { i++; x_1=Coor_x_l0(data_fin[i].index-index_0_b); if (lead1_plot_button_status.HRate ) y_1=170-data_fin[i].HR/2; if (lead1_plot_button_status.STFine ) y_1=60+Coor_y_l1(data_fin[i].l1_ST80); if (lead1_plot_button_status.STslFine ) y_1=60+Coor_y_l1(data_fin[i].l1_ST80-data_fin[i].l1_ST20); if (lead1_plot_button_status.ISOJ ) y_1=(long)(160-1000.0*(data_fin[i].nISO +data_fin[i].nJ)/FSAMP/3); if ((x_1 > x_0 ) OR PLOT_ALL ) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XDrawLine(my_display, my_window, my_gc, x_0,160, x_0,163); XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); x_0=x_1; y_0=y_1; } } // end while XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XDrawLine(my_display, my_window, my_gc, x_0,160, x_0,163); XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); fin_display_end=i-1; } // if hrate if ( references_index[1] >= 0 ){ for (i=0; i <= references_index[1]; i++){ if ( (data_raw[references[1][i].raw_index].index >= index_0_b) && (data_raw[references[1][i].raw_index].index <= index_0_e) ) { act_loc=FALSE; if ( Is_code(1,i,0,0) ){ act_loc= act_reference[1].set && ( act_reference[1].typ == 2 ) && (act_reference[1].index == i); if (( i == reference_act[1] ) OR act_loc ) { XAllocNamedColor(my_display, cmap,set_color1, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } x_0=Coor_x_l0(data_raw[references[1][i].raw_index].index-index_0_b); XDrawLine(my_display, my_window, my_gc, x_0,10, x_0,160); XDrawString(my_display, my_window, my_gc, x_0 - 10 ,10, "LR",2); if (( i == reference_act[1] ) OR act_loc ) { XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } } else // other ref { if ( i == reference_act[1] ) { XAllocNamedColor(my_display, cmap,set_color2, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } x_0=Coor_x_l0(data_raw[references[1][i].raw_index].index-index_0_b); XDrawLine(my_display, my_window, my_gc, x_0,10, x_0,160); get_display_code(1,i); XDrawString(my_display, my_window, my_gc, x_0 - 10 ,10, ref_code,2); if ( i == reference_act[1] ) { XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } } } } // end for } // plot ref. if ( loc_interval_b[1].set && (data_raw[loc_interval_b[1].raw_index].index >= index_0_b) && (data_raw[loc_interval_b[1].raw_index].index <= index_0_e) ) { x_0=Coor_x_l0(data_raw[loc_interval_b[1].raw_index].index-index_0_b); XAllocNamedColor(my_display, cmap,set_color3, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XDrawLine(my_display, my_window, my_gc, x_0,10, x_0,160); XDrawString(my_display, my_window, my_gc, x_0 - 9 ,20, "B",1); } if ( loc_interval_e[1].set && (data_raw[loc_interval_e[1].raw_index].index >= index_0_b) && (data_raw[loc_interval_e[1].raw_index].index <= index_0_e) ) { x_0=Coor_x_l0(data_raw[loc_interval_e[1].raw_index].index-index_0_b); XAllocNamedColor(my_display, cmap,set_color3, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XDrawLine(my_display, my_window, my_gc, x_0,10, x_0,160); XDrawString(my_display, my_window, my_gc, x_0 - 9 ,20, "E",1); } if ( global_set && (data_raw[global_ref[1].raw_index].index >= index_0_b) && (data_raw[global_ref[1].raw_index].index <= index_0_e) ) { XAllocNamedColor(my_display, cmap,set_color1, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); x_0=Coor_x_l0(data_raw[global_ref[1].raw_index].index-index_0_b); XDrawLine(my_display, my_window, my_gc, x_0,10, x_0,160); XDrawString(my_display, my_window, my_gc, x_0 - 10 ,10, "GR",2); } if ( Marker[1].set && (data_raw[Marker[1].raw_index].index >= index_0_b) && (data_raw[Marker[1].raw_index].index <= index_0_e) ) { XAllocNamedColor(my_display, cmap,set_color3, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); x_0=Coor_x_l0(data_raw[Marker[1].raw_index].index-index_0_b); XDrawLine(my_display, my_window, my_gc, x_0,10, x_0,160); XDrawString(my_display, my_window, my_gc, x_0 - 11 ,20, "M",1); x_1=Coor_x_l0(data_fin[Marker[1].fine_index].index-index_0_b); if ( x_1 == x_0) x_1++; XDrawLine(my_display, my_window, my_gc, x_1,80, x_1,160); } // end marker XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } // end draw_lead1_A(void) void draw_lead2_A(void) { long i, begmisx, begmise, j, ischonbegx, ischonbege; long x_0, x_1, x_x, y_0, y_1, y1_0,y1_1; Bool act_loc; Bool pl_epi=FALSE, pl_epii=FALSE; Bool epi_error=FALSE, epi_error_first=TRUE; long ep_index=0; int ep_status_i=0, ep_status_r=0, ep_status_o=0; index_0_b=TimeToIndex(diagram_time_begin_lead); index_0_e=TimeToIndex(diagram_time_begin_lead+time_scale_0); index_0=index_0_b; XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); if ( ovr2_l0 ) { XAllocNamedColor(my_display, cmap,set_color4, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); i=0; while (data_raw[i].index < index_0_b) i++; x_0=Coor_x_l0(data_raw[i].index-index_0_b); y_0=Coor_y_l2(data_raw[i].l0_ST80); while ( (data_raw[i].index < index_0_e ) && ( i < raw_last_index) ){ i++; x_1=Coor_x_l0(data_raw[i].index-index_0_b); y_1=Coor_y_l2(data_raw[i].l0_ST80); if ((x_1 > x_0 ) OR PLOT_ALL ) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); x_0=x_1; y_0=y_1; } } // end while XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } if ( ovr2_l1 ) { XAllocNamedColor(my_display, cmap,set_color5, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); i=0; while (data_raw[i].index < index_0_b) i++; x_0=Coor_x_l0(data_raw[i].index-index_0_b); y_0=Coor_y_l2(data_raw[i].l1_ST80); while ( (data_raw[i].index < index_0_e ) && ( i < raw_last_index) ){ i++; x_1=Coor_x_l0(data_raw[i].index-index_0_b); y_1=Coor_y_l2(data_raw[i].l1_ST80); if ((x_1 > x_0 ) OR PLOT_ALL ) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); x_0=x_1; y_0=y_1; } } // end while XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } if ( ovr2_app ) { XAllocNamedColor(my_display, cmap,set_color3, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); i=0; while (data_raw[i].index < index_0_b) i++; x_0=Coor_x_l0(data_raw[i].index-index_0_b); y_0=Coor_y_l2(data_raw[i].lin_v[2]); while ( (data_raw[i].index < index_0_e ) && ( i < raw_last_index) ){ i++; x_1=Coor_x_l0(data_raw[i].index-index_0_b); y_1=Coor_y_l2(data_raw[i].lin_v[2]); if ((x_1 > x_0 ) OR PLOT_ALL ) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); x_0=x_1; y_0=y_1; } } // end while XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); i=0; while (data_raw[i].index < index_0_b) i++; raw_display_begin=i; x_0=Coor_x_l0(data_raw[i].index-index_0_b); if (status_unsubtracted2 ) {y_0=Coor_y_l2(data_raw[i].l2_ST80);} else {y_0=Coor_y_l2(data_raw[i].sub_v[2]);} if (lead2_plot_button_status.HRRaw ) { y1_0=170-data_raw[i].HR/2; XDrawString(my_display, my_window, my_gc, 2,161, "Heart Rate Raw [bpm]",20);} if (lead2_plot_button_status.STslRaw ) { y1_0=60+Coor_y_l2(data_raw[i].l2_ST80-data_raw[i].l2_ST20); XDrawString(my_display, my_window, my_gc, 2,161, "ST Slope Raw [uV]",17);} if ((lead2_plot_button_status.Episodes ) && (references_index[2] >= 0)) { XDrawString(my_display, my_window, my_gc, 2,161, "Episodes",8);} begmisx = -1; begmise = -1; ischonbegx = -1; ischonbege = -1; while ( (data_raw[i].index < index_0_e ) && ( i < raw_last_index) ){ if ((lead2_plot_button_status.Episodes ) && (references_index[2] >= 0)) { while (( references[2][ep_index].raw_index <= i ) && ( ep_index <= references_index[2] )){ if (Is_code(2,ep_index,-1,1)){ if ( (ep_status_i == 0 ) && (ep_status_r == 0) && (ep_status_o == 0) ) { ep_status_i=1; pl_epi=TRUE; pl_epii=TRUE;} else { epi_error = TRUE; pl_epi=FALSE; pl_epii=FALSE;} } if (Is_code(2,ep_index,2,1)){ if (( ep_status_i == 1 ) && (ep_status_r == 0) && (ep_status_o == 0)) { ep_status_i=2; pl_epi=TRUE; pl_epii=TRUE;} else { if (ep_status_i == 0) begmisx = i; ischonbegx = i; epi_error = TRUE; pl_epi=FALSE; pl_epii=FALSE;} } if (Is_code(2,ep_index,-3,1)){ if (( ep_status_i == 2 ) && (ep_status_r == 0) && (ep_status_o == 0)) { ep_status_i=0; pl_epi=FALSE; pl_epii=FALSE;} else { if (ep_status_i == 0) begmise = i; ischonbege = i; epi_error = TRUE; pl_epi=FALSE; pl_epii=FALSE;} } if (Is_code(2,ep_index,-1,7)){ if (( ep_status_r == 0 ) && (ep_status_i == 0) && (ep_status_o == 0)) { ep_status_r=1; pl_epi=TRUE;} else { epi_error = TRUE; pl_epi=FALSE; } } if (Is_code(2,ep_index,2,7)){ if (( ep_status_r == 1 ) && (ep_status_i == 0) && (ep_status_o == 0)) { ep_status_r=2; pl_epi=TRUE;} else { if (ep_status_r == 0) begmisx = i; epi_error = TRUE; pl_epi=FALSE; } } if (Is_code(2,ep_index,-3,7)){ if (( ep_status_r == 2 ) && (ep_status_i == 0) && (ep_status_o == 0)) { ep_status_r=0; pl_epi=FALSE;} else { if (ep_status_r == 0) begmise = i; epi_error = TRUE; pl_epi=FALSE; } } if (Is_code(2,ep_index,-1,11)){ if (( ep_status_o == 0 ) && (ep_status_r == 0) && (ep_status_i == 0)) { ep_status_o=1; pl_epi=TRUE;} else { epi_error = TRUE; pl_epi=FALSE; } } if (Is_code(2,ep_index,2,11)){ if (( ep_status_o == 1 ) && (ep_status_r == 0) && (ep_status_i == 0)) { ep_status_o=2; pl_epi=TRUE;} else { if (ep_status_o == 0) begmisx = i; epi_error = TRUE; pl_epi=FALSE; } } if (Is_code(2,ep_index,-3,11)){ if (( ep_status_o == 2 ) && (ep_status_r == 0) && (ep_status_i == 0)) { ep_status_o=0; pl_epi=FALSE;} else { if (ep_status_o == 0) begmise = i; epi_error = TRUE; pl_epi=FALSE; } } if ( epi_error) sprintf(message2, "Time: %14s",mstimstr(data_raw[references[2][ep_index].raw_index].index)); ep_index++; if ((ep_index > references_index[2] ) && ((ep_status_i != 0) || (ep_status_r != 0) || (ep_status_o != 0)) ) { epi_error=TRUE; sprintf(message2, "Time: %14s",mstimstr(data_raw[references[2][references_index[2]].raw_index].index)); } if ( epi_error && epi_error_first ) { strcpy(message1,"Lead 2: Inconsistent episode !"); // // warning_message(2); // epi_error=FALSE; ep_status_i=0; ep_status_r=0; ep_status_o=0; epi_error_first=FALSE; } } if (pl_epi) { XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XDrawLine(my_display, my_window, my_gc, x_0,116, x_0,120); // XDrawLine(my_display, my_window, my_gc, x_0,146, x_0,150); XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); } // if (pl_epii) { // XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); // XDrawLine(my_display, my_window, my_gc, x_0,136, x_0,140); // XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); // // pl_epi=ep_status != 0; // } } // end episodes i++; x_1=Coor_x_l0(data_raw[i].index-index_0_b); if (status_unsubtracted2 ) {y_1=Coor_y_l2(data_raw[i].l2_ST80);} else {y_1=Coor_y_l2(data_raw[i].sub_v[2]);} if ((x_1 > x_0 ) OR PLOT_ALL ) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XDrawLine(my_display, my_window, my_gc, x_0,156, x_0,160); XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); if (lead2_plot_button_status.HRRaw ){ y1_1=170-data_raw[i].HR/2; XDrawLine(my_display, my_window, my_gc, x_0,y1_0, x_1,y1_1); y1_0=y1_1; } if (lead2_plot_button_status.STslRaw ){ y1_1=60+Coor_y_l2(data_raw[i].l2_ST80-data_raw[i].l2_ST20); XDrawLine(my_display, my_window, my_gc, x_0,y1_0, x_1,y1_1); y1_0=y1_1; } x_0=x_1; y_0=y_1; } } // end while XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XDrawLine(my_display, my_window, my_gc, x_0,156, x_0,160); XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); if (begmisx != -1 && begmise != -1) { j=begmise; begmisx = begmise = -1; x_x=Coor_x_l0(data_raw[j].index-index_0_b); while ( (data_raw[j].index >= index_0_b ) && ( j >= 0) ) { XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XDrawLine(my_display, my_window, my_gc, x_x,116, x_x,120); // XDrawLine(my_display, my_window, my_gc, x_x,146, x_x,150); XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); j--; x_x=Coor_x_l0(data_raw[j].index-index_0_b); } } // if (ischonbegx != -1 && ischonbege != -1) { // j=ischonbegx; ischonbegx = ischonbege = -1; // x_x=Coor_x_l0(data_raw[j].index-index_0_b); // while ( (data_raw[j].index >= index_0_b ) && ( j >= 0) ) { // XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); // XDrawLine(my_display, my_window, my_gc, x_x,136, x_x,140); // XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); // j--; // x_x=Coor_x_l0(data_raw[j].index-index_0_b); // } // } raw_display_end=i-1; fin_display_end=raw_display_end; while ( (data_fin[fin_display_end].index < index_0_e) && ( fin_display_end < fin_last_index) ) fin_display_end++; fin_display_end=fin_display_end-1; i=0; while (data_fin[i].index < index_0_b) i++; fin_display_begin=i; if (lead2_plot_button_status.HRate OR lead2_plot_button_status.STFine OR lead2_plot_button_status.STslFine OR lead2_plot_button_status.ISOJ ){ x_0=Coor_x_l0(data_fin[i].index-index_0_b); if (lead2_plot_button_status.HRate ) { y_0=170-data_fin[i].HR/2; XDrawString(my_display, my_window, my_gc, 2,161, "Heart Rate [bpm]",16);} if (lead2_plot_button_status.STFine ) { y_0=60+Coor_y_l2(data_fin[i].l2_ST80); XDrawString(my_display, my_window, my_gc, 2,161, "ST Fine [uV]",12);} if (lead2_plot_button_status.STslFine ) { y_0=60+Coor_y_l2(data_fin[i].l2_ST80-data_fin[i].l2_ST20); XDrawString(my_display, my_window, my_gc, 2,161, "ST Slope Fine [uV]",18);} if (lead2_plot_button_status.ISOJ ) { y_0=(long)(160-1000.0*(data_fin[i].nISO +data_fin[i].nJ)/FSAMP/3); XDrawString(my_display, my_window, my_gc, 2,161, "ISO - J [ms]",12);} while ( (data_fin[i].index < index_0_e) && ( i < fin_last_index) ) { i++; x_1=Coor_x_l0(data_fin[i].index-index_0_b); if (lead2_plot_button_status.HRate ) y_1=170-data_fin[i].HR/2; if (lead2_plot_button_status.STFine ) y_1=60+Coor_y_l2(data_fin[i].l2_ST80); if (lead2_plot_button_status.STslFine ) y_1=60+Coor_y_l2(data_fin[i].l2_ST80-data_fin[i].l2_ST20); if (lead2_plot_button_status.ISOJ ) y_1=(long)(160-1000.0*(data_fin[i].nISO +data_fin[i].nJ)/FSAMP/3); if ((x_1 > x_0 ) OR PLOT_ALL ) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XDrawLine(my_display, my_window, my_gc, x_0,160, x_0,163); XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); x_0=x_1; y_0=y_1; } } // end while XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XDrawLine(my_display, my_window, my_gc, x_0,160, x_0,163); XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); fin_display_end=i-1; } // if hrate if ( references_index[2] >= 0 ){ for (i=0; i <= references_index[2]; i++){ if ( (data_raw[references[2][i].raw_index].index >= index_0_b) && (data_raw[references[2][i].raw_index].index <= index_0_e) ) { act_loc=FALSE; if ( Is_code(2,i,0,0) ){ act_loc= act_reference[2].set && ( act_reference[2].typ == 2 ) && (act_reference[2].index == i); if (( i == reference_act[2] ) OR act_loc ) { XAllocNamedColor(my_display, cmap,set_color1, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } x_0=Coor_x_l0(data_raw[references[2][i].raw_index].index-index_0_b); XDrawLine(my_display, my_window, my_gc, x_0,10, x_0,160); XDrawString(my_display, my_window, my_gc, x_0 - 10 ,10, "LR",2); if (( i == reference_act[2] ) OR act_loc ) { XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } } else // other ref { if ( i == reference_act[2] ) { XAllocNamedColor(my_display, cmap,set_color2, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } x_0=Coor_x_l0(data_raw[references[2][i].raw_index].index-index_0_b); XDrawLine(my_display, my_window, my_gc, x_0,10, x_0,160); get_display_code(2,i); XDrawString(my_display, my_window, my_gc, x_0 - 10 ,10, ref_code,2); if ( i == reference_act[2] ) { XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } } } } // end for } // plot ref. if ( loc_interval_b[2].set && (data_raw[loc_interval_b[2].raw_index].index >= index_0_b) && (data_raw[loc_interval_b[2].raw_index].index <= index_0_e) ) { x_0=Coor_x_l0(data_raw[loc_interval_b[2].raw_index].index-index_0_b); XAllocNamedColor(my_display, cmap,set_color3, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XDrawLine(my_display, my_window, my_gc, x_0,10, x_0,160); XDrawString(my_display, my_window, my_gc, x_0 - 9 ,20, "B",1); } if ( loc_interval_e[2].set && (data_raw[loc_interval_e[2].raw_index].index >= index_0_b) && (data_raw[loc_interval_e[2].raw_index].index <= index_0_e) ) { x_0=Coor_x_l0(data_raw[loc_interval_e[2].raw_index].index-index_0_b); XAllocNamedColor(my_display, cmap,set_color3, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XDrawLine(my_display, my_window, my_gc, x_0,10, x_0,160); XDrawString(my_display, my_window, my_gc, x_0 - 9 ,20, "E",1); } if ( global_set && (data_raw[global_ref[2].raw_index].index >= index_0_b) && (data_raw[global_ref[2].raw_index].index <= index_0_e) ) { XAllocNamedColor(my_display, cmap,set_color1, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); x_0=Coor_x_l0(data_raw[global_ref[2].raw_index].index-index_0_b); XDrawLine(my_display, my_window, my_gc, x_0,10, x_0,160); XDrawString(my_display, my_window, my_gc, x_0 - 10 ,10, "GR",2); } if ( Marker[2].set && (data_raw[Marker[2].raw_index].index >= index_0_b) && (data_raw[Marker[2].raw_index].index <= index_0_e) ) { XAllocNamedColor(my_display, cmap,set_color3, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); x_0=Coor_x_l0(data_raw[Marker[2].raw_index].index-index_0_b); XDrawLine(my_display, my_window, my_gc, x_0,10, x_0,160); XDrawString(my_display, my_window, my_gc, x_0 - 11 ,20, "M",1); x_1=Coor_x_l0(data_fin[Marker[2].fine_index].index-index_0_b); if ( x_1 == x_0) x_1++; XDrawLine(my_display, my_window, my_gc, x_1,80, x_1,160); } // end marker XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } // end draw_lead2_A(void) void draw_grid_lead0(int lead) { Bool draw_type_B, draw_type_C, draw_type_D, draw_type_E; switch(lead){ case 0: my_display=l_b_display; my_window=l_b_window; my_gc= gcLead0; draw_type_B=lead0_plot_button_status.HRate OR lead0_plot_button_status.HRRaw; draw_type_C=lead0_plot_button_status.STFine OR lead0_plot_button_status.STslFine OR lead0_plot_button_status.STslRaw ; draw_type_D=lead0_plot_button_status.Episodes; draw_type_E=lead0_plot_button_status.ISOJ; break; case 1: my_display=l_b1_display; my_window=l_b1_window; my_gc= gcLead1; draw_type_B=lead1_plot_button_status.HRate OR lead1_plot_button_status.HRRaw; draw_type_C=lead1_plot_button_status.STFine OR lead1_plot_button_status.STslFine OR lead1_plot_button_status.STslRaw ; draw_type_D=lead1_plot_button_status.Episodes; draw_type_E=lead1_plot_button_status.ISOJ; break; case 2: my_display=l_b2_display; my_window=l_b2_window; my_gc= gcLead2; draw_type_B=lead2_plot_button_status.HRate OR lead2_plot_button_status.HRRaw; draw_type_C=lead2_plot_button_status.STFine OR lead2_plot_button_status.STslFine OR lead2_plot_button_status.STslRaw ; draw_type_D=lead2_plot_button_status.Episodes; draw_type_E=lead2_plot_button_status.ISOJ; break; } XGCValues line_type; long c_Time=0, hours=0,hours_l=0, minutes=0, seconds=0; char pr_time[8]; int i,j, lx, lxx, ampl, imax; long x_0, x_1, y_0, y_1; XClearWindow(my_display, my_window); XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); cmap=XDefaultColormap(my_display, DefaultScreen(my_display)); XAllocNamedColor(my_display, cmap,"white", &col, & unused); XSetBackground(my_display, my_gc, col.pixel); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XDrawLine(my_display, my_window, my_gc, 1120, 0, 1120,180); XDrawLine(my_display, my_window, my_gc, 160, 0, 160,180); XDrawLine(my_display, my_window, my_gc, 160,60, 1120,60); XDrawLine(my_display, my_window, my_gc, 160,120, 1120,120); line_type.line_style=LineOnOffDash; XChangeGC(my_display, my_gc, GCLineStyle,&line_type); XDrawLine(my_display, my_window, my_gc, 160,10, 1120,10); XDrawLine(my_display, my_window, my_gc, 160,20, 1120,20); XDrawLine(my_display, my_window, my_gc, 160,30, 1120,30); XDrawLine(my_display, my_window, my_gc, 160,40, 1120,40); XDrawLine(my_display, my_window, my_gc, 160,50, 1120,50); XDrawLine(my_display, my_window, my_gc, 160,70, 1120,70); XDrawLine(my_display, my_window, my_gc, 160,80, 1120,80); XDrawLine(my_display, my_window, my_gc, 160,90, 1120,90); XDrawLine(my_display, my_window, my_gc, 160,100, 1120,100); XDrawLine(my_display, my_window, my_gc, 160,110, 1120,110); XDrawLine(my_display, my_window, my_gc, 160,130, 1120,130); XDrawLine(my_display, my_window, my_gc, 160,140, 1120,140); XDrawLine(my_display, my_window, my_gc, 160,150, 1120,150); XDrawLine(my_display, my_window, my_gc, 160,160, 1120,160); XDrawString(my_display, my_window, my_gc, 142,20, " 2",2); XDrawString(my_display, my_window, my_gc, 142,40, " 1",2); XDrawString(my_display, my_window, my_gc, 142,60, " 0",2); XDrawString(my_display, my_window, my_gc, 142,80, "-1",2); XDrawLine(my_display, my_window, my_gc, 1120, 0, 1120,180); XDrawLine(my_display, my_window, my_gc, 160, 0, 160,180); XDrawLine(my_display, my_window, my_gc, 160,60, 1120,60); XDrawLine(my_display, my_window, my_gc, 160,120, 1120,120); line_type.line_style=LineOnOffDash; XChangeGC(my_display, my_gc, GCLineStyle,&line_type); XDrawLine(my_display, my_window, my_gc, 160,10, 1120,10); XDrawLine(my_display, my_window, my_gc, 160,20, 1120,20); XDrawLine(my_display, my_window, my_gc, 160,30, 1120,30); XDrawLine(my_display, my_window, my_gc, 160,40, 1120,40); XDrawLine(my_display, my_window, my_gc, 160,50, 1120,50); XDrawLine(my_display, my_window, my_gc, 160,70, 1120,70); XDrawLine(my_display, my_window, my_gc, 160,80, 1120,80); XDrawLine(my_display, my_window, my_gc, 160,90, 1120,90); XDrawLine(my_display, my_window, my_gc, 160,100, 1120,100); XDrawLine(my_display, my_window, my_gc, 160,110, 1120,110); XDrawLine(my_display, my_window, my_gc, 160,130, 1120,130); XDrawLine(my_display, my_window, my_gc, 160,140, 1120,140); XDrawLine(my_display, my_window, my_gc, 160,150, 1120,150); XDrawLine(my_display, my_window, my_gc, 160,160, 1120,160); XDrawLine(my_display, my_window, my_gc, 240,10, 240,180); XDrawLine(my_display, my_window, my_gc, 320,10, 320,180); XDrawLine(my_display, my_window, my_gc, 400,10, 400,180); XDrawLine(my_display, my_window, my_gc, 480,10, 480,180); XDrawLine(my_display, my_window, my_gc, 560,10, 560,180); XDrawLine(my_display, my_window, my_gc, 640,10, 640,180); XDrawLine(my_display, my_window, my_gc, 720,10, 720,180); XDrawLine(my_display, my_window, my_gc, 800,10, 800,180); XDrawLine(my_display, my_window, my_gc, 880,10, 880,180); XDrawLine(my_display, my_window, my_gc, 960,10, 960,180); XDrawLine(my_display, my_window, my_gc, 1040,10, 1040,180); line_type.line_style=LineSolid; XChangeGC(my_display, gcLead0, GCLineStyle,&line_type); XDrawString(my_display, my_window, my_gc, 2,174, "[time]",6); sprintf(pr_buff, "[units] [uV] R:%s[%d]", inp_rec_name, lead); XDrawString(my_display, my_window, my_gc, 2,12,pr_buff, strlen(pr_buff)); XAllocNamedColor(my_display, cmap,"white", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XFillRectangle(my_display, my_window, my_gc, 1,54,130,38); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); c_Time = diagram_time_begin_lead; for(i = 0; i < 12; i++) { TimeToHoursMinSec(c_Time, &hours, &minutes, &seconds, &hours_l); sprintf(pr_time, "%ld:%ld:%ld", hours_l, minutes, seconds); XDrawString(my_display, my_window, my_gc, (162 + i * 80), 174, pr_time, strlen(pr_time)); c_Time +=scale_time_tick; } if (draw_type_B ){ XDrawString(my_display, my_window, my_gc, 134,120, "100",3); XDrawString(my_display, my_window, my_gc, 136,140, " 60",3); } if (draw_type_C ){ XDrawString(my_display, my_window, my_gc, 142,100, " 1",2); XDrawString(my_display, my_window, my_gc, 142,120, " 0",2); XDrawString(my_display, my_window, my_gc, 142,140, "-1",2); } if (draw_type_E ){ XDrawString(my_display, my_window, my_gc, 134,120, "120",3); XDrawString(my_display, my_window, my_gc, 136,140, " 60",3); } switch(lead){ case 0: write_ref_data_l0(); draw_lead0_A();set_buttons_lead0(); break; case 1: write_ref_data_l1(); draw_lead1_A();set_buttons_lead1(); break; case 2: write_ref_data_l2(); draw_lead2_A();set_buttons_lead2(); break; } // end lead } // end draw_grid_lead0 void draw_ovrly_coeff(void) { int i; long x_0, x_1, y_0, y_1; my_display=k_b_display; my_window=k_b_window; my_gc= gckoeff; XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); index_0_b=TimeToIndex(diagram_time_begin_lead); index_0_e=TimeToIndex(diagram_time_begin_lead+time_scale_0); index_0=index_0_b; if ( ovr_coef ) { XAllocNamedColor(my_display, cmap,"white", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XFillRectangle(my_display, my_window, my_gc, 100,144,30,14); XAllocNamedColor(my_display, cmap,set_color3, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); i=raw_display_begin; x_0=Coor_x_l0(data_raw[i].index-index_0_b); if ( KL_coefficents ) { y_0=(long)(157-(double(data_raw[i].ST_f) /5.0 /ampl_c)); } else { y_0=(long)(157-(double(data_raw[i].QRS_f) /5.0 /ampl_c)); } while ( (data_raw[i].index < index_0_e ) && ( i < raw_last_index) ){ i++; x_1=Coor_x_l0(data_raw[i].index-index_0_b); if ( KL_coefficents ) { y_1=(long)(157-(double(data_raw[i].ST_f) /5.0 /ampl_c)); } else { y_1=(long)(157-(double(data_raw[i].QRS_f) /5.0 /ampl_c)); } if ((x_1 > x_0 ) OR PLOT_ALL ) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); x_0=x_1; y_0=y_1; } } // end while XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XDrawString(my_display, my_window, my_gc, 5,157, "KL 5 ......................Dist..",34); } } // end draw_ovrly_coeff(void); void draw_grid_coeff(void) { my_display=k_b_display; my_window=k_b_window; my_gc= gckoeff; XGCValues line_type; long c_Time=0, hours=0,hours_l=0, minutes=0, seconds=0; char pr_time[8], pr_m[1]; int i,j, lx, lxx, ampl, imax; long x_0, x_1, y_0, y_1; XClearWindow(my_display, my_window); XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); cmap=XDefaultColormap(my_display, DefaultScreen(my_display)); XAllocNamedColor(my_display, cmap,"white", &col, & unused); XSetBackground(my_display, my_gc, col.pixel); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XDrawLine(my_display, my_window, my_gc, 1120, 0, 1120,196); XDrawLine(my_display, my_window, my_gc, 160, 0, 160,196); XDrawLine(my_display, my_window, my_gc, 160,37, 1120,37); XDrawLine(my_display, my_window, my_gc, 160,67, 1120,67); XDrawLine(my_display, my_window, my_gc, 160,97, 1120,97); XDrawLine(my_display, my_window, my_gc, 160,127, 1120,127); XDrawLine(my_display, my_window, my_gc, 160,157, 1120,157); line_type.line_style=LineOnOffDash; XChangeGC(my_display, my_gc, GCLineStyle,&line_type); XDrawLine(my_display, my_window, my_gc, 160,7, 1120,7); XDrawLine(my_display, my_window, my_gc, 160,17, 1120,17); XDrawLine(my_display, my_window, my_gc, 160,27, 1120,27); XDrawLine(my_display, my_window, my_gc, 160,47, 1120,47); XDrawLine(my_display, my_window, my_gc, 160,57, 1120,57); XDrawLine(my_display, my_window, my_gc, 160,77, 1120,77); XDrawLine(my_display, my_window, my_gc, 160,87, 1120,87); XDrawLine(my_display, my_window, my_gc, 160,107, 1120,107); XDrawLine(my_display, my_window, my_gc, 160,117, 1120,117); XDrawLine(my_display, my_window, my_gc, 160,137, 1120,137); XDrawLine(my_display, my_window, my_gc, 160,147, 1120,147); XDrawLine(my_display, my_window, my_gc, 160,167, 1120,167); XDrawLine(my_display, my_window, my_gc, 160,177, 1120,177); XDrawString(my_display, my_window, my_gc, 145,17, " 1",2); XDrawString(my_display, my_window, my_gc, 145,37, " 0",2); XDrawString(my_display, my_window, my_gc, 145,67, " 0",2); XDrawString(my_display, my_window, my_gc, 145,97, " 0",2); XDrawString(my_display, my_window, my_gc, 145,127, " 0",2); XDrawString(my_display, my_window, my_gc, 145,157, " 0",2); XDrawString(my_display, my_window, my_gc, 145,177, "-1",2); XDrawString(my_display, my_window, my_gc, 145,47, " 1",2); XDrawString(my_display, my_window, my_gc, 145,77, " 1",2); XDrawString(my_display, my_window, my_gc, 145,107, " 1",2); XDrawString(my_display, my_window, my_gc, 145,137, " 1",2); XDrawLine(my_display, my_window, my_gc, 240,7, 240,180); XDrawLine(my_display, my_window, my_gc, 320,7, 320,180); XDrawLine(my_display, my_window, my_gc, 400,7, 400,180); XDrawLine(my_display, my_window, my_gc, 480,7, 480,180); XDrawLine(my_display, my_window, my_gc, 560,7, 560,180); XDrawLine(my_display, my_window, my_gc, 640,7, 640,180); XDrawLine(my_display, my_window, my_gc, 720,7, 720,180); XDrawLine(my_display, my_window, my_gc, 800,7, 800,180); XDrawLine(my_display, my_window, my_gc, 880,7, 880,180); XDrawLine(my_display, my_window, my_gc, 960,7, 960,180); XDrawLine(my_display, my_window, my_gc, 1040,7, 1040,180); line_type.line_style=LineSolid; XChangeGC(my_display, gcLead0, GCLineStyle,&line_type); XDrawString(my_display, my_window, my_gc, 2,190, "[time]",6); sprintf(pr_buff, "[units] [std] R:%s", inp_rec_name); XDrawString(my_display, my_window, my_gc, 2,12,pr_buff, strlen(pr_buff)); c_Time = diagram_time_begin_lead; for(i = 0; i < 12; i++) { TimeToHoursMinSec(c_Time, &hours, &minutes, &seconds, &hours_l); sprintf(pr_time, "%ld:%ld:%ld", hours, minutes, seconds); XDrawString(my_display, my_window, my_gc, (162 + i * 80), 190, pr_time, strlen(pr_time)); c_Time +=scale_time_tick; } int k1_0, k2_0, k3_0, k4_0, k5_0, k1_1, k2_1, k3_1, k4_1, k5_1; index_0_b=TimeToIndex(diagram_time_begin_lead); index_0_e=TimeToIndex(diagram_time_begin_lead+time_scale_0); index_0=index_0_b; XDrawString(my_display, my_window, my_gc, 5,37, "KL 1 ..................................",40); XDrawString(my_display, my_window, my_gc, 5,67, "KL 2 ..................................",40); XDrawString(my_display, my_window, my_gc, 5,97, "KL 3 ..................................",40); XDrawString(my_display, my_window, my_gc, 5,127, "KL 4 ..................................",40); XDrawString(my_display, my_window, my_gc, 5,157, "KL 5 ..................................",40); XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); i=0; while (data_raw[i].index < index_0_b) i++; raw_display_begin=i; x_0=Coor_x_l0(data_raw[i].index-index_0_b); if ( KL_coefficents ) { k1_0=(int)(37-(double(data_raw[i].STk1) /5.0 /ampl_c)); k2_0=(int)(67-(double(data_raw[i].STk2) /5.0 /ampl_c)); k3_0=(int)(97-(double(data_raw[i].STk3) /5.0 /ampl_c)); k4_0=(int)(127-(double(data_raw[i].STk4) /5.0 /ampl_c)); k5_0=(int)(157-(double(data_raw[i].STk5) /5.0 /ampl_c)); } else { k1_0=(int)(37-(double(data_raw[i].QRSk1) /5.0 /ampl_c)); k2_0=(int)(67-(double(data_raw[i].QRSk2) /5.0 /ampl_c)); k3_0=(int)(97-(double(data_raw[i].QRSk3) /5.0 /ampl_c)); k4_0=(int)(127-(double(data_raw[i].QRSk4) /5.0 /ampl_c)); k5_0=(int)(157-(double(data_raw[i].QRSk5) /5.0 /ampl_c)); } while ( (data_raw[i].index < index_0_e ) && ( i < raw_last_index) ){ i++; x_1=Coor_x_l0(data_raw[i].index-index_0_b); if ( KL_coefficents ) { k1_1=(int)(37-(double(data_raw[i].STk1) /5.0 /ampl_c)); k2_1=(int)(67-(double(data_raw[i].STk2) /5.0 /ampl_c)); k3_1=(int)(97-(double(data_raw[i].STk3) /5.0 /ampl_c)); k4_1=(int)(127-(double(data_raw[i].STk4) /5.0 /ampl_c)); k5_1=(int)(157-(double(data_raw[i].STk5) /5.0 /ampl_c)); } else { k1_1=(int)(37-(double(data_raw[i].QRSk1) /5.0 /ampl_c)); k2_1=(int)(67-(double(data_raw[i].QRSk2) /5.0 /ampl_c)); k3_1=(int)(97-(double(data_raw[i].QRSk3) /5.0 /ampl_c)); k4_1=(int)(127-(double(data_raw[i].QRSk4) /5.0 /ampl_c)); k5_1=(int)(157-(double(data_raw[i].QRSk5) /5.0 /ampl_c)); } if ((x_1 > x_0 ) OR PLOT_ALL ) { XDrawLine(my_display, my_window, my_gc, x_0,k1_0, x_1,k1_1); k1_0=k1_1; XDrawLine(my_display, my_window, my_gc, x_0,k2_0, x_1,k2_1); k2_0=k2_1; XDrawLine(my_display, my_window, my_gc, x_0,k3_0, x_1,k3_1); k3_0=k3_1; XDrawLine(my_display, my_window, my_gc, x_0,k4_0, x_1,k4_1); k4_0=k4_1; XDrawLine(my_display, my_window, my_gc, x_0,k5_0, x_1,k5_1); k5_0=k5_1; x_0=x_1; } } // end while raw_display_end=i-1; draw_ovrly_coeff(); for (i=0; i<= 2; i++){ if ( Marker[i].set && (data_raw[Marker[i].raw_index].index >= index_0_b) && (data_raw[Marker[i].raw_index].index <= index_0_e) ) { XAllocNamedColor(my_display, cmap,set_color3, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); x_0=Coor_x_l0(data_raw[Marker[i].raw_index].index-index_0_b); XDrawLine(my_display, my_window, my_gc, x_0,10, x_0,177); sprintf(pr_m,"%d",i); XDrawString(my_display, my_window, my_gc, x_0 - 6 ,10, pr_m,1); } // end marker } XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } // end draw_grid_coeff void data_new_r_read(void) { long i,j,i_fin; long data_b_0, data_e_0, t_index; char time[15], time_b[15],time_e[15]; long R_end; data_b_0=reference_mstime_index - (150 * FSAMP + FSAMP / 2 ); // - 150 sec= 2.5 min as max display offset + 1/2 avr ( 1000 ms /2 ) data_e_0=reference_mstime_index + (150 * FSAMP + FSAMP / 2 ); // + 150 sec as max display offset i=LEN_BUFF_D-1; while ( data_b_0 < 0 ){ L_buff_R[0][i]=0; L_buff_R[1][i]=0; L_buff_R[2][i]=0; L_buff_R[3][i]=0; L_buff_R[4][i]=0; L_buff_R[5][i]=0; data_b_0++; i--; } t_index=data_b_0; i_fin=0; while ( data_fin[i_fin].index < t_index ) i_fin++; isigsettime(data_b_0); while ( i >= 0 ) { if (getvec(v_sample) <= 0) { fprintf(stderr,"Error reading data (1)\n"); exit(-1); } for (j = 0; j< nsig; j++) L_buff_R[j][i]=v_sample[j]; L_buff_R[4][i]=t_index; if ( t_index == data_fin[i_fin].index ) { L_buff_R[5][i]=1; i_fin++; } else { L_buff_R[5][i]=0; } t_index++; i--; } for (j = 0; j< 6; j++) R_buff_R[j][0]= L_buff_R[j][0]; i=1; R_end= LEN_BUFF_D; while ( data_raw[raw_last_index].index < data_e_0 ){ R_buff_R[0][data_e_0]=0; R_buff_R[1][data_e_0]=0; R_buff_R[2][data_e_0]=0; R_buff_R[3][data_e_0]=0; R_buff_R[4][data_e_0]=0; R_buff_R[5][data_e_0]=0; data_e_0--; R_end--; } while ( i < R_end ) { if (getvec(v_sample) <= 0) { fprintf(stderr,"Error reading data (2)\n"); exit(-1); } for (j = 0; j< nsig; j++) R_buff_R[j][i]=v_sample[j]; R_buff_R[4][i]=t_index; if ( t_index == data_fin[i_fin].index ) { R_buff_R[5][i]=1; i_fin++; } else { R_buff_R[5][i]=0; } t_index++; i++; } i--; } // end data_new_r_read void data_new_m_read(void) { long i,j,i_fin; long data_b_0, data_e_0, t_index; char time[15], time_b[15],time_e[15]; long R_end; data_b_0=data_mstime_index - (150 * FSAMP + FSAMP / 2 ); // - 150 sec= 2.5 min as max display offset + 1/2 avr ( 1000 ms /2 ) data_e_0=data_mstime_index + (150 * FSAMP + FSAMP / 2 ); // + 150 sec as max display offset i=LEN_BUFF_D-1; while ( data_b_0 < 0 ){ L_buff_M[0][i]=0; L_buff_M[1][i]=0; L_buff_M[2][i]=0; L_buff_M[3][i]=0; L_buff_M[4][i]=0; L_buff_M[5][i]=0; data_b_0++; i--; } t_index=data_b_0; i_fin=0; while ( data_fin[i_fin].index < t_index ) i_fin++; isigsettime(data_b_0); while ( i >= 0 ) { if (getvec(v_sample) <= 0) { fprintf(stderr,"Error reading data (3)\n"); exit(-1); } for (j = 0; j< nsig; j++) L_buff_M[j][i]=v_sample[j]; L_buff_M[4][i]=t_index; if ( t_index == data_fin[i_fin].index ) { L_buff_M[5][i]=1; i_fin++; } else { L_buff_M[5][i]=0; } t_index++; i--; } for (j = 0; j< 6; j++) R_buff_M[j][0]= L_buff_M[j][0]; i=1; R_end= LEN_BUFF_D-1; while ( data_raw[raw_last_index].index < data_e_0 ){ R_buff_M[0][R_end]=0; R_buff_M[1][R_end]=0; R_buff_M[2][R_end]=0; R_buff_M[3][R_end]=0; R_buff_M[4][R_end]=0; R_buff_M[5][R_end]=0; data_e_0--; R_end--; } while ( i < R_end) { if (getvec(v_sample) <= 0) { fprintf(stderr,"Error reading data (4)\n"); exit(-1); } for (j = 0; j< nsig; j++) R_buff_M[j][i]=v_sample[j]; R_buff_M[4][i]=t_index; if ( t_index == data_fin[i_fin].index ) { R_buff_M[5][i]=1; i_fin++; } else { R_buff_M[5][i]=0; } t_index++; i++; } i--; } // end data_new_m_read void data_plot_marker_x(int Data_lead_x, int pos) { long d_display_index; long j; long i; long x_0, x_1, y_0, y_1, y_s; float y; long x; char time[15], time_b[15]; float v_iso, v_j, v_j80; XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); d_display_index= data_scale * FSAMP / 2; v_iso = avr_in_avrbeat(Data_lead_x, Marker[Data_lead].nISO,Marker[Data_lead].NS); v_j = avr_in_avrbeat(Data_lead_x,- Marker[Data_lead].nJ,Marker[Data_lead].NS); v_j80 = avr_in_avrbeat(Data_lead_x,- Marker[Data_lead].nJ80,Marker[Data_lead].NS); i=d_display_index; y=L_buff_M[Data_lead_x][i]- v_iso; x=L_buff_M[4][i]-L_buff_M[4][d_display_index]; x_0=Coor_x_data(x); y_0=Coor_y_data_M(y)+pos; while ( i > d_avrg_index ){ i--; y=L_buff_M[Data_lead_x][i]- v_iso; x=L_buff_M[4][i]-L_buff_M[4][d_display_index]; x_1=Coor_x_data(x); y_1=Coor_y_data_M(y)+pos; if ( L_buff_M[5][i] == 1 ) XDrawString(my_display, my_window, my_gc, x_0,191, "*",1); if ((x_1 > x_0 ) OR PLOT_ALL ) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); x_0=x_1; y_0=y_1; } } // end while XDrawLine(my_display, my_window, my_gc, x_0,y_0-10, x_0,y_0+10); i = d_avrg_index; y=A_buff_M[Data_lead_x][125-i]- v_iso; x=L_buff_M[4][i]-L_buff_M[4][d_display_index]; x_0=Coor_x_data(x); y_0=Coor_y_data_M(y)+pos; XDrawLine(my_display, my_window, my_gc, x_0,y_0-10, x_0,y_0+10); while ( i > -d_avrg_index ){ if (( i == Marker[Data_lead].nISO ) && ( data_scale < 3 )) { y_s=Coor_y_data_M(0.0)+pos; plot_point_symbol(set_marker, x_0, y_s); } if (( -i == Marker[Data_lead].nJ ) && ( data_scale < 3 )) { y_s=Coor_y_data_M(v_j- v_iso)+pos; plot_point_symbol(set_marker, x_0, y_s); } i--; y=A_buff_M[Data_lead_x][125-i]- v_iso; if ( i >= 0 ) { x=L_buff_M[4][i]-L_buff_M[4][d_display_index]; if ( L_buff_M[5][i] == 1 ) XDrawString(my_display, my_window, my_gc, x_0,191, "*",1); } else { x=R_buff_M[4][-i]-L_buff_M[4][d_display_index]; if ( R_buff_M[5][-i] == 1 ) XDrawString(my_display, my_window, my_gc, x_0,191, "*",1); } x_1=Coor_x_data(x); y_1=Coor_y_data_M(y)+pos; if ((x_1 > x_0 ) OR PLOT_ALL ) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); x_0=x_1; y_0=y_1; } if (( -i == Marker[Data_lead].nJ80 ) && ( data_scale < 3 )) { y_s=Coor_y_data_M(v_j80 - v_iso)+pos; plot_point_symbol(set_marker, x_0, y_s); } } // end while XDrawLine(my_display, my_window, my_gc, x_0,y_0-10, x_0,y_0+10); i = d_avrg_index; y=R_buff_M[Data_lead_x][i]- v_iso; x=R_buff_M[4][i]-L_buff_M[4][d_display_index]; x_0=Coor_x_data(x); y_0=Coor_y_data_M(y)+pos; XDrawLine(my_display, my_window, my_gc, x_0,y_0-10, x_0,y_0+10); while ( i < d_display_index ){ i++; y=R_buff_M[Data_lead_x][i]- v_iso; x=R_buff_M[4][i]-L_buff_M[4][d_display_index]; x_1=Coor_x_data(x); y_1=Coor_y_data_M(y)+pos; if ( R_buff_M[5][i] == 1 ) XDrawString(my_display, my_window, my_gc, x_0,191, "*",1); if ((x_1 > x_0 ) OR PLOT_ALL ) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); x_0=x_1; y_0=y_1; } } // end while XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); } // data_plot_marker_x void data_plot_marker(void) { int pos0, pos1, pos2, posx; pos0=0; pos1=0; pos2=0; posx=0; if ( data_ovrly_shift ) { pos0= -40; pos1=0; pos2=40; switch ( Data_lead){ case 0: posx=pos0; break; case 1: posx=pos1; break; case 2: posx=pos2; break; }; }; if ( data_ovr_l0 ) { XAllocNamedColor(my_display, cmap,set_color4, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); data_plot_marker_x(0,pos0); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } if ( data_ovr_l1 ) { XAllocNamedColor(my_display, cmap,set_color5, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); data_plot_marker_x(1,pos1); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } if ( data_ovr_l2 ) { XAllocNamedColor(my_display, cmap,set_color6, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); data_plot_marker_x(2,pos2); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } data_plot_marker_x(Data_lead,posx); } // end data_plot_marker void data_plot_ref_x(int Data_lead_x ,int pos, Bool plot_box, int Data_lead_x_act) { long d_display_index; long j; long i; long x_0, x_1, y_0, y_1, y_s; float y; long x; char time[15], time_b[15]; float v_iso, v_j, v_j80; XSetLineAttributes(my_display, my_gc,set_line_width, LineSolid, CapRound, JoinRound); d_display_index= data_scale * FSAMP / 2; i=d_display_index; v_iso = avr_in_avrbeat_r(Data_lead_x, act_ref_data[Data_lead_x_act].nISO,act_ref_data[Data_lead_x_act].NS); v_j = avr_in_avrbeat_r(Data_lead_x,- act_ref_data[Data_lead_x_act].nJ,act_ref_data[Data_lead_x_act].NS); v_j80 = avr_in_avrbeat_r(Data_lead_x,- act_ref_data[Data_lead_x_act].nJ80,act_ref_data[Data_lead_x_act].NS); i=d_display_index; y=L_buff_R[Data_lead_x][i]-v_iso; x=L_buff_R[4][i]-L_buff_R[4][d_display_index]; x_0=Coor_x_data(x); y_0=Coor_y_data_M(y)-180+pos; while ( i > d_avrg_index ){ i--; y=L_buff_R[Data_lead_x][i]-v_iso; x=L_buff_R[4][i]-L_buff_R[4][d_display_index]; x_1=Coor_x_data(x); y_1=Coor_y_data_M(y)-180+pos; if ( L_buff_R[5][i] == 1 ) XDrawString(my_display, my_window, my_gc, x_0,20, "*",1); if ((x_1 > x_0 ) OR PLOT_ALL) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); x_0=x_1; y_0=y_1; } } // end while XDrawLine(my_display, my_window, my_gc, x_0,y_0-10, x_0,y_0+10); i = d_avrg_index; y=A_buff_R[Data_lead_x][125-i]-v_iso; x=L_buff_R[4][i]-L_buff_R[4][d_display_index]; x_0=Coor_x_data(x); y_0=Coor_y_data_M(y)-180+pos; XDrawLine(my_display, my_window, my_gc, x_0,y_0-10, x_0,y_0+10); while ( i > -d_avrg_index ){ if (( i == act_ref_data[Data_lead_x_act].nISO ) && (plot_box ) && ( data_scale < 3 )){ y_s=Coor_y_data_M(0.0)-180+pos; plot_point_symbol(set_marker, x_0, y_s); } if (( -i == act_ref_data[Data_lead_x_act].nJ ) && (plot_box ) && ( data_scale < 3 )){ y_s=Coor_y_data_M(v_j - v_iso)-180+pos; plot_point_symbol(set_marker, x_0, y_s); } i--; y=A_buff_R[Data_lead_x][125-i]- v_iso; if ( i >= 0 ) { x=L_buff_R[4][i]-L_buff_R[4][d_display_index]; if (( L_buff_R[5][i] == 1 ) && ( !data_ovr_ref)) XDrawString(my_display, my_window, my_gc, x_0,20, "*",1); } else { x=R_buff_R[4][-i]-L_buff_R[4][d_display_index]; if (( R_buff_R[5][-i] == 1 ) && ( !data_ovr_ref)) XDrawString(my_display, my_window, my_gc, x_0,20, "*",1); } x_1=Coor_x_data(x); y_1=Coor_y_data_M(y)-180+pos; if ((x_1 > x_0 ) OR PLOT_ALL) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); x_0=x_1; y_0=y_1; } if (( -i == act_ref_data[Data_lead_x_act].nJ80 ) && (plot_box ) && ( data_scale < 3 )){ y_s=Coor_y_data_M(v_j80 - v_iso)-180+pos; plot_point_symbol(set_marker, x_0, y_s); } } // end while XDrawLine(my_display, my_window, my_gc, x_0,y_0-10, x_0,y_0+10); i = d_avrg_index; y=R_buff_R[Data_lead_x][i]- v_iso; x=R_buff_R[4][i]-L_buff_R[4][d_display_index]; x_0=Coor_x_data(x); y_0=Coor_y_data_M(y)-180+pos; XDrawLine(my_display, my_window, my_gc, x_0,y_0-10, x_0,y_0+10); while ( i < d_display_index ){ i++; y=R_buff_R[Data_lead_x][i]- v_iso; x=R_buff_R[4][i]-L_buff_R[4][d_display_index]; x_1=Coor_x_data(x); y_1=Coor_y_data_M(y)-180+pos; if ( R_buff_R[5][i] == 1 ) XDrawString(my_display, my_window, my_gc, x_0,20, "*",1); if ((x_1 > x_0 ) OR PLOT_ALL) { XDrawLine(my_display, my_window, my_gc, x_0,y_0, x_1,y_1); x_0=x_1; y_0=y_1; } } // end while XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); } // data_plot_ref_x void data_plot_reference(void) { long d_display_index; char time[15], time_b[15]; int pos0, pos1, pos2, posx; pos0=0; pos1=0; pos2=0; posx=0; if ( data_ovrly_shift ) { pos0= -40; pos1=0; pos2=40; switch ( Data_lead){ case 0: posx=pos0; break; case 1: posx=pos1; break; case 2: posx=pos2; break; }; }; if ( data_ovr_l0 ) { XAllocNamedColor(my_display, cmap,set_color4, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); data_plot_ref_x(0,pos0, TRUE, Data_lead); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } if ( data_ovr_l1 ) { XAllocNamedColor(my_display, cmap,set_color5, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); data_plot_ref_x(1,pos1, TRUE, Data_lead); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } if ( data_ovr_l2 ) { XAllocNamedColor(my_display, cmap,set_color6, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); data_plot_ref_x(2,pos2, TRUE, Data_lead); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } if ( data_ovr_ref ) { XAllocNamedColor(my_display, cmap,set_color3, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); data_plot_ref_x(Data_lead,posx+180, FALSE, Data_lead); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); } data_plot_ref_x(Data_lead,posx, TRUE, Data_lead); } // end data_plot_reference void draw_grid_data(void) { XGCValues line_type; int i,x, x_0, x_1; long d_display_index; float v_j80, v_j20, v_iso, v_isor, v_j80r; float v_j80_str, v_j20_str, v_iso_str, v_isor_str, v_j80r_str; int v_j80_str_i, v_j20_str_i, v_slo_str_i, v_dev_str_i; d_display_index= data_scale * FSAMP / 2; // XClearWindow(my_display, my_window, 0, 0, 1128,1087); XAllocNamedColor(my_display, cmap,"white", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XFillRectangle(my_display, my_window, my_gc, 0, 0, 1128, 1087); XSetLineAttributes(my_display, my_gc,1, LineSolid, CapRound, JoinRound); cmap=XDefaultColormap(my_display, DefaultScreen(my_display)); XAllocNamedColor(my_display, cmap,set_color7, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); x=L_buff_R[4][d_avrg_index]-L_buff_R[4][d_display_index]; x_0=Coor_x_data(x); x=R_buff_R[4][d_avrg_index]-L_buff_R[4][d_display_index]; x_1=Coor_x_data(x); if ( d_avrg_index > 0 ) XFillRectangle(my_display, my_window, my_gc, x_0,0,x_1-x_0,550); // 360 XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XDrawLine(my_display, my_window, my_gc, 1120, 0, 1120,550); // XDrawLine(my_display, my_window, my_gc, 160, 0, 160,550); // XDrawLine(my_display, my_window, my_gc, 160,90, 1120,90); // XDrawLine(my_display, my_window, my_gc, 160,180, 1120,180); // XDrawLine(my_display, my_window, my_gc, 160,270, 1120,270); // XDrawLine(my_display, my_window, my_gc, 160,550, 1120,550); // XDrawLine(my_display, my_window, my_gc, 640,0, 640,550); // line_type.line_style=LineOnOffDash; XChangeGC(my_display, my_gc, GCLineStyle,&line_type); XDrawLine(my_display, my_window, my_gc, 160,10, 1120,10); for (i=30; i <= 550; i+=20) // < 360 XDrawLine(my_display, my_window, my_gc, 160,i, 1120,i); x=(int)data_grid_tick; i=1; while(x < 480) { XDrawLine(my_display, my_window, my_gc, 640 + x, 0, 640 + x, 550); // 360 XDrawLine(my_display, my_window, my_gc, 639 - x, 0, 639 - x, 550); // 360 i++; x = (int)(i * data_grid_tick); } XDrawString(my_display, my_window, my_gc, 143,10, " 2",2); XDrawString(my_display, my_window, my_gc, 143,50, " 1",2); XDrawString(my_display, my_window, my_gc, 143,90, " 0",2); XDrawString(my_display, my_window, my_gc, 143,130, "-1",2); XDrawString(my_display, my_window, my_gc, 143,170, "-2",2); XDrawString(my_display, my_window, my_gc, 143,190, " 2",2); XDrawString(my_display, my_window, my_gc, 143,230, " 1",2); XDrawString(my_display, my_window, my_gc, 143,270, " 0",2); XDrawString(my_display, my_window, my_gc, 143,310, "-1",2); XDrawString(my_display, my_window, my_gc, 143,350, "-2",2); XDrawString(my_display, my_window, my_gc, 143,390, "-3",2); // XDrawString(my_display, my_window, my_gc, 143,430, "-4",2); // XDrawString(my_display, my_window, my_gc, 143,470, "-5",2); // XDrawString(my_display, my_window, my_gc, 143,510, "-6",2); // XDrawString(my_display, my_window, my_gc, 143,550, "-7",2); // sprintf(pr_buff, "[units] [uV] R:%s", inp_rec_name); XDrawString(my_display, my_window, my_gc, 2,12,pr_buff, strlen(pr_buff)); if ( act_reference[Data_lead].set ){ sprintf(pr_buff,"Refer."); XDrawString(my_display, my_window, my_gc, 2,90, pr_buff,strlen(pr_buff)); sprintf(pr_buff,"%s", mstimstr(data_fin[act_ref_data[Data_lead].fine_index].index)); XDrawString(my_display, my_window, my_gc, 50,90, pr_buff,strlen(pr_buff)); v_isor = avr_in_avrbeat_r(Data_lead, act_ref_data[Data_lead].nISO,act_ref_data[Data_lead].NS); v_j80r = avr_in_avrbeat_r(Data_lead,- act_ref_data[Data_lead].nJ80,act_ref_data[Data_lead].NS); } else { XDrawString(my_display, my_window, my_gc, 2,90, "NO Reference set .....",22); v_isor=0.0; v_j80r= avr_in_avrbeat(Data_lead,- Marker[Data_lead].nJ80,Marker[Data_lead].NS) -avr_in_avrbeat(Data_lead, Marker[Data_lead].nISO,Marker[Data_lead].NS); } if ( Marker[Data_lead].set ) { v_iso = avr_in_avrbeat(Data_lead, Marker[Data_lead].nISO,Marker[Data_lead].NS); v_j20 = avr_in_avrbeat(Data_lead,- (Marker[Data_lead].nJ+5),Marker[Data_lead].NS); v_j80 = avr_in_avrbeat(Data_lead,- Marker[Data_lead].nJ80,Marker[Data_lead].NS); XAllocNamedColor(my_display, cmap,set_color8, &col, & unused); XSetForeground(my_display, my_gc, col.pixel); XFillRectangle(my_display, my_window, my_gc, 1,13,140,25); XAllocNamedColor(my_display, cmap,"black", &col, & unused); XSetForeground(my_display, my_gc, col.pixel); sprintf(pr_buff,"HRate: %d [bpm]",Marker[Data_lead].fine_HR); XDrawString(my_display, my_window, my_gc, 2,36, pr_buff,strlen(pr_buff)); sprintf(pr_buff,"Mean:"); XDrawString(my_display, my_window, my_gc, 2,54, pr_buff,strlen(pr_buff)); if ( reference_act[Data_lead] == -1 && references_index[Data_lead] == -1) { sprintf(pr_buff,"%4d/%5d",Marker[Data_lead].NS, act_ref_data[Data_lead].NS ); } else if ( reference_act[Data_lead] > -1 ) { sprintf(pr_buff,"%4d/%4d",Marker[Data_lead].NS, references[Data_lead][reference_act[Data_lead]].NS ); } else { sprintf(pr_buff,"%4d/%4s",Marker[Data_lead].NS, " " ); } XDrawString(my_display, my_window, my_gc, 46,54, pr_buff,strlen(pr_buff)); sprintf(pr_buff,"[smp]"); XDrawString(my_display, my_window, my_gc, 105,54, pr_buff,strlen(pr_buff)); sprintf(pr_buff,"ABeat:"); XDrawString(my_display, my_window, my_gc, 2,66, pr_buff,strlen(pr_buff)); if ( reference_act[Data_lead] == -1 && references_index[Data_lead] == -1) { sprintf(pr_buff,"%4d/%4d",Marker[Data_lead].window, act_ref_data[Data_lead].window ); } else if ( reference_act[Data_lead] > -1 ) { sprintf(pr_buff,"%4d/%4d",Marker[Data_lead].window, references[Data_lead][reference_act[Data_lead]].window ); } else { sprintf(pr_buff,"%4d/%4s",Marker[Data_lead].window, " "); } XDrawString(my_display, my_window, my_gc, 42,66, pr_buff,strlen(pr_buff)); sprintf(pr_buff,"[sec]"); XDrawString(my_display, my_window, my_gc, 112,66, pr_buff,strlen(pr_buff)); strcpy(pr_buff,"PB:"); strcpy(pr_buff,"PE:"); sprintf(pr_buff,"ISO:"); if ( reference_act[Data_lead] == -1 && references_index[Data_lead] == -1 ) { sprintf(pr_buff,"%4d/%4d",-1000* Marker[Data_lead].nISO/FSAMP, -1000* act_ref_data[Data_lead].nISO/FSAMP); } else if ( reference_act[Data_lead] > -1) { sprintf(pr_buff,"%4d/%4d",-1000* Marker[Data_lead].nISO/FSAMP, -1000* references[Data_lead][reference_act[Data_lead]].nISO/FSAMP); } else { sprintf(pr_buff,"%4d/%4s",-1000* Marker[Data_lead].nISO/FSAMP, " "); } sprintf(pr_buff,"[ms]"); strcpy(pr_buff,"Q:"); sprintf(p