i have keypressfcn seems work whenever i'm obtaining new data , plotting it. when i'm not obtaining new data, keypressfcn seems no longer work. if press corresponding key, once data range , begin taking data again, closes figure.
i'm confused why happening. data collection happens if condition met, changing keypressfcn , exitflag inside while loop , should happening every time loop occurs, don't see why wouldn't exit figure. here code,
disp('dicom slice viewer'); disp('" ": exit on space key'); global kpressed; kpressed = 0; %init figure on screen global fig; fig=dicom_sliceviewer_createfigure(1,dicomparam); set(fig.fig,'keypressfcn','global kpressed; global fig; kpressed = get(fig.fig,''currentchar'');'); exitflag = 0; while (exitflag == 0) naviparam=navi_acquire(naviparam); naviparam=navi_calc_data(naviparam); %calibration calculation !to checked! dicompos = dicomparam.calib.navi2dicom*[naviparam.data.endo_refoffsetposvec;1]; ixr=round(min(max(dicompos(1),1),dicomparam.sx)); iyr=round(min(max(dicompos(2),1),dicomparam.sy)); izr=round(min(max(dicompos(3),1),dicomparam.sz)); if kpressed ~= 0 switch kpressed case ' ' exitflag = 1; disp('**** exit dicom slice viewer ****') end kpressed = 0; end if naviparam.datastr(5:11)~='missing' %refresh plot 3 standard cuts set(fig.sub1im, 'cdata', reshape(dicomparam.vd(ixr,:,:),[dicomparam.sy dicomparam.sz])); set(fig.sub2im, 'cdata', reshape(dicomparam.vd(:,iyr,:),[dicomparam.sx dicomparam.sz])); set(fig.sub3im, 'cdata', reshape(dicomparam.vd(:,:,izr),[dicomparam.sx dicomparam.sy])); drawnow; end end close(fig.fig); clear global;
solved own problem!
all did move "drawnow" out of if statement. allowed me draw new data if taken, allowed internal parameters updated in figure believe.
Comments
Post a Comment