0001 function vb_do_mark_trigger(plot_spec, draw_spec)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 if ~exist('plot_spec', 'var'), plot_spec = []; end;
0035 if ~exist('draw_spec', 'var'), draw_spec = []; end;
0036 [plot_spec, draw_spec] = inner_check_arguments(plot_spec, draw_spec);
0037
0038
0039
0040
0041
0042 vb_define_process_trigger;
0043
0044 my_data = plot_spec.data;
0045
0046 plot_idx = plot_spec.plot_idx;
0047 trigger_idx = plot_spec.trigger_channel_idx;
0048
0049
0050 data_color = draw_spec.data_color;
0051 trigger_color = draw_spec.trigger_data_color;
0052
0053
0054
0055 if isempty(plot_spec.trigger_sample_idx)
0056 figure('Position', DPT_WINDOW_POSITION);
0057
0058
0059 for ch = plot_idx'
0060 dh = plot(my_data(ch,:), 'Color', data_color); hold on;
0061 set(dh, 'Tag', DPT_DATALINE_TAG);
0062 end
0063
0064 inner_set_controls(plot_spec.output_file);
0065
0066
0067
0068 else
0069
0070
0071 trigger_list = plot_spec.trigger_sample_idx;
0072
0073
0074
0075
0076
0077
0078 trigger_num = size(trigger_list,1);
0079
0080 for ntr = 1:trigger_num
0081 figure;
0082
0083 for ch = plot_idx'
0084 dh = plot(my_data(ch,:), 'Color', data_color); hold on;
0085 set(dh, 'Tag', DPT_DATALINE_TAG);
0086 end
0087
0088
0089 trigger_line_gap = 10;
0090 trigger_line_clr = draw_spec.trigger_line_color;
0091
0092 y_limit = get(gca, 'YLim');
0093 y_min = y_limit(1);
0094 y_max = y_limit(2);
0095
0096
0097 y_data = [y_min:trigger_line_gap:y_max];
0098
0099
0100 plot_index = trigger_list(ntr).beg_idx;
0101
0102
0103 for this_x = plot_index
0104
0105 vb_util_line_trigger(this_x, y_data, trigger_line_clr);
0106 end
0107
0108
0109 if trigger_num > 1
0110 output_file = sprintf('%s_%d', plot_spec.output_file, ntr);
0111 else
0112 output_file = plot_spec.output_file;
0113 end
0114
0115 inner_set_controls(output_file);
0116 end
0117
0118
0119 end
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140 function [plot_spec, draw_spec] = inner_check_arguments(plot_spec, draw_spec)
0141
0142 vb_define_process_trigger;
0143
0144 if isempty(plot_spec)
0145 error('plot_spec is a required parameter');
0146 end
0147
0148 if ~isfield(plot_spec, 'data')
0149 error('data is a required field of plot_spec');
0150 end
0151
0152 if ~isfield(plot_spec, 'plot_idx')
0153 error('plot_idx is a required field of plot_spec');
0154 elseif ~isempty( find(plot_spec.plot_idx > size(plot_spec.data,1) ...
0155 | plot_spec.plot_idx < 1))
0156 error('invalid index : plot_spec.plot_idx');
0157 else
0158 plot_spec.plot_idx = vb_util_arrange_list(plot_spec.plot_idx);
0159 end
0160
0161
0162
0163
0164 if ~isfield(plot_spec, 'trigger_channel_idx') ...
0165 || isempty(plot_spec.trigger_channel_idx)
0166
0167 plot_spec.trigger_channel_idx = [];
0168
0169 elseif ~isempty(find(plot_spec.trigger_channel_idx > size(plot_spec.data,1) ...
0170 | plot_spec.trigger_channel_idx < 1))
0171
0172 error('invalid index : plot_spec.trigger_channel_idx');
0173
0174 else
0175 plot_spec.trigger_channel_idx = ...
0176 vb_util_arrange_list(plot_spec.trigger_channel_idx);
0177 end
0178
0179
0180
0181
0182 if ~isfield(plot_spec, 'trigger_sample_idx')
0183 plot_spec.trigger_sample_idx = [];
0184 end
0185
0186
0187
0188
0189 if ~isfield(plot_spec, 'output_file') || isempty(plot_spec.output_file)
0190 plot_spec.output_file = sprintf('.%strigger_%s.mat', filesep, date);
0191 end
0192
0193
0194
0195
0196 if isempty(draw_spec)
0197 draw_spec.data_color = DPT_DEFAULT_ND_COLOR;
0198 draw_spec.trigger_data_color = DPT_DEFAULT_TD_COLOR;
0199 draw_spec.trigger_line_color = DPT_DEFAULT_TL_COLOR;
0200 else
0201 if ~isfield(draw_spec, 'data_color') ...
0202 || isempty(draw_spec.data_color)
0203 draw_spec.data_color = DPT_DEFAULT_ND_COLOR;
0204 end
0205 if ~isfield(draw_spec, 'trigger_data_color') ...
0206 || isempty(draw_spec.trigger_data_color)
0207 draw_spec.trigger_data_color = DPT_DEFAULT_TD_COLOR;
0208 end
0209 if ~isfield(draw_spec, 'trigger_line_color') ...
0210 || isempty(draw_spec.trigger_line_color)
0211 draw_spec.trigger_line_color = DPT_DEFAULT_TL_COLOR;
0212 end
0213 end
0214
0215
0216
0217
0218
0219
0220 function inner_set_controls(output_file)
0221 vb_define_process_trigger;
0222
0223
0224 if ~exist('MAX_ZOOM_RANGE', 'var'), MAX_ZOOM_RANGE = 100; end;
0225
0226
0227 set(gcf,'WindowButtonDownFcn','vb_cb_clip_trigger down')
0228 set(gcf,'WindowButtonMotionFcn','vb_cb_clip_trigger move')
0229 set(gcf,'WindowButtonUpFcn','vb_cb_clip_trigger up')
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240 ud.output_file = output_file;
0241
0242
0243
0244 ud.drag_switch = true;
0245
0246
0247 xlim = get(gca, 'XLim');
0248 ylim = get(gca, 'YLim');
0249
0250 axis_ends = [];
0251 axis_ends = vb_axisends_set(axis_ends, 'ORIGINAL', 'X', xlim(1), xlim(2));
0252 axis_ends = vb_axisends_set(axis_ends, 'PREVIOUS', 'X', xlim(1), xlim(2));
0253 axis_ends = vb_axisends_set(axis_ends, 'SLIDER', 'X', xlim(1), xlim(2));
0254
0255 axis_ends = vb_axisends_set(axis_ends, 'ORIGINAL', 'Y', ylim(1), ylim(2));
0256 axis_ends = vb_axisends_set(axis_ends, 'PREVIOUS', 'Y', ylim(1), ylim(2));
0257 axis_ends = vb_axisends_set(axis_ends, 'SLIDER', 'Y', ylim(1), ylim(2));
0258
0259 ud.axis_ends = axis_ends;
0260
0261 set(gcf, 'UserData', ud);
0262 set(gcf, 'Tag', DPT_FIGURE_TAG);
0263
0264
0265
0266
0267 if ud.drag_switch == true
0268 mode_str = DPT_LBL_MODE_RANGE;
0269 else
0270 mode_str = DPT_LBL_MODE_LINE;
0271 end
0272
0273
0274
0275 SLD_L = 50;
0276 SLD_B = 10;
0277 SLD_W = 100;
0278 SLD_H = 15;
0279
0280
0281 LBL_W = 50;
0282 LBL_H = SLD_H;
0283 LEFT = SLD_L;
0284 uicontrol('Tag', 'zoom_x_label', ...
0285 'Style','Text', ...
0286 'String',DPT_LBL_X_ZOOM, ...
0287 'Position',[LEFT SLD_B LBL_W LBL_H]);
0288
0289 LEFT = LEFT + LBL_W;
0290
0291 sld_x = uicontrol('Tag', DPT_CTRL_TAG_ZOOM_X, ...
0292 'Style','Slider', ...
0293 'Min',1, 'Max',MAX_ZOOM_RANGE, ...
0294 'SliderStep', [1/MAX_ZOOM_RANGE 10/MAX_ZOOM_RANGE], ...
0295 'Value', 1, ...
0296 'Callback',['vb_cb_clip_trigger(''zoom_slide_x'')'], ...
0297 'Position',[LEFT SLD_B SLD_W SLD_H]);
0298
0299
0300 SLD_Y_L = 30;
0301 SLD_Y_B = 50;
0302 SLD_Y_W = SLD_H;
0303 SLD_Y_H = SLD_W;
0304 sld_y = uicontrol('Tag', DPT_CTRL_TAG_ZOOM_Y, ...
0305 'Style','Slider', ...
0306 'Min',1, 'Max',MAX_ZOOM_RANGE, ...
0307 'SliderStep', [1/MAX_ZOOM_RANGE 10/MAX_ZOOM_RANGE], ...
0308 'Value', 1, ...
0309 'Callback',['vb_cb_clip_trigger(''zoom_slide_y'')'], ...
0310 'Position',[SLD_Y_L SLD_Y_B SLD_Y_W SLD_Y_H]);
0311
0312 LBL_Y_L = 5;
0313 LBL_Y_B = SLD_Y_B + SLD_Y_H;
0314 uicontrol('Tag', DPT_LBL_Y_ZOOM, ...
0315 'Style', 'Text', ...
0316 'String', DPT_LBL_Y_ZOOM, ...
0317 'Position',[LBL_Y_L LBL_Y_B LBL_W LBL_H]);
0318
0319
0320 SLD_Y_L = SLD_Y_L;
0321 SLD_Y_B = LBL_Y_B + LBL_H + 10;
0322 SLD_Y_W = SLD_H;
0323 SLD_Y_H = SLD_W;
0324 sld_y = uicontrol('Tag', DPT_CTRL_TAG_ZOOM_Y, ...
0325 'Style','Slider', ...
0326 'Min',-100, 'Max',MAX_ZOOM_RANGE, ...
0327 'SliderStep', [1/MAX_ZOOM_RANGE 10/MAX_ZOOM_RANGE], ...
0328 'Value', 0, ...
0329 'Callback',['vb_cb_clip_trigger(''move_slide_y'')'], ...
0330 'Position',[SLD_Y_L SLD_Y_B SLD_Y_W SLD_Y_H]);
0331
0332
0333 LBL_Y_B = SLD_Y_B + SLD_Y_H;
0334 uicontrol('Tag', DPT_LBL_Y_MOVE, ...
0335 'Style', 'Text', ...
0336 'String', DPT_LBL_Y_MOVE, ...
0337 'Position',[LBL_Y_L LBL_Y_B LBL_W LBL_H]);
0338
0339
0340
0341
0342 BTN_L = LEFT + SLD_W + 20;
0343 BTN_B = SLD_B;
0344 BTN_W = 80;
0345 BTN_H = 20;
0346 BTN_I = BTN_W + 5;
0347
0348
0349
0350 LEFT = BTN_L;
0351
0352
0353
0354
0355 control_btn_1 = uicontrol(gcf, ...
0356 'Tag', DPT_CTRL_TAG_MODE_SWITCH, ...
0357 'Style', 'Pushbutton', ...
0358 'Position', [LEFT BTN_B BTN_W BTN_H], ...
0359 'String', mode_str, ...
0360 'Callback', ['vb_cb_clip_trigger(''mode'')'] ...
0361 );
0362
0363
0364
0365 LEFT = LEFT + BTN_I;
0366 control_btn_2 = uicontrol(gcf, ...
0367 'Style', 'Pushbutton', ...
0368 'Position', [LEFT BTN_B BTN_W BTN_H], ...
0369 'String', DPT_LBL_ZOOMIN, ...
0370 'Callback', ['vb_cb_clip_trigger(''zoomin'')'] ...
0371 );
0372
0373
0374
0375 LEFT = LEFT + BTN_I;
0376 control_btn_3 = uicontrol(gcf, ...
0377 'Style', 'Pushbutton', ...
0378 'Position', [LEFT BTN_B BTN_W BTN_H], ...
0379 'String', DPT_LBL_PREVIOUS, ...
0380 'Callback', ['vb_cb_clip_trigger(''prev'')'] ...
0381 );
0382
0383
0384
0385
0386 LEFT = LEFT + BTN_I;
0387 control_btn_4 = uicontrol(gcf, ...
0388 'Style', 'Pushbutton', ...
0389 'Position', [LEFT BTN_B BTN_W BTN_H], ...
0390 'String', DPT_LBL_INITIALIZE, ...
0391 'Callback', ['vb_cb_clip_trigger(''restore'')'] ...
0392 );
0393
0394
0395
0396 LEFT = LEFT + BTN_I;
0397 control_btn_5 = uicontrol(gcf, ...
0398 'Style', 'Pushbutton', ...
0399 'Position', [LEFT BTN_B BTN_W BTN_H], ...
0400 'String', DPT_LBL_SAVE, ...
0401 'Callback', ['vb_cb_clip_trigger(''save'')'] ...
0402 );
0403
0404
0405
0406
0407
0408
0409
0410
0411
0412
0413
0414 select_xrange('init', gca);
0415
0416
0417
0418