How to move a line as fast as possible ...

조회 수: 2 (최근 30일)
Song
Song 2017년 3월 9일
댓글: Song 2017년 3월 9일
Hi, I am doing an app which can show signals. In this app, I would like to add a cursor line along with the movement of the mouse to show signal values. I tried my best to simplify the algorithm, but still the line follows my cursor not fast enough. You can see the effect in the attached gif. Cursor line runs always behind cursor.
With the prevous Matlab version, I can draw a XOR'ed line which fits my application perfectly. Since I am using 2016 now, there is no such property any more. Is there some other ways to implement this?
Thanks!
  댓글 수: 4
Adam
Adam 2017년 3월 9일
편집: Adam 2017년 3월 9일
If that is all you are doing it is doubtful you can write code any faster than that. If you were replotting the line every time then, of course, this would be my first suggestion, but since you are already doing the minimum of editing to the graphics object there isn't really any less you can do if that is literally the only code on moving the mouse.
In my implementation I actually drag the line so it is in a ButtonDownFcn rather than a mouse move, I don't know if that makes a difference. My code of importance though is:
function doLineMoveFunc( obj )
currentPoint = get( obj.axesHandle, 'CurrentPoint' );
xPos = currentPoint( 1, 1 );
xPos = doValidateXLocation( obj, xPos );
xData = get( obj.hLine, 'XData' );
xData(:) = roundLocation( obj, xPos );
set( obj.hLine, 'XData', xData );
end
so similar to what you do. I also have some validation code thrown in so it actually does more than simply setting the xdata. Without further functions attached to the moving it follows the dragging very closely though. I can't be bothered to work out how to record a gif though!
Song
Song 2017년 3월 9일
Nice job adam. It would be glad for me to see how the dragging/following speed would look like on your machine with higher Matlab version (>2015). The gif recorder I used is called "gifrecorder" from http://gifrecorder.com/. I think there are open-source alternatives than this :P

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by