Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93831406
createNewDataCursor.m
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Dec 1, 20:53
Size
1 KB
Mime Type
text/html
Expires
Tue, Dec 3, 20:53 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22711936
Attached To
rINSTCONTROL Instrument Control
createNewDataCursor.m
View Options
function
hNewDataCursor
=
createNewDataCursor
(
hThis
,
hTarget
)
%
CREATENEWDATACURSOR
Creates
a
new
data
cursor
%
%
Thanks
to
<
a
href
=
"http://www.mathworks.com/matlabcentral/profile/authors/3354683-yaroslav"
>
Yaroslav
Don
</
a
>
for
his
assistance
in
updating
cursorbar
for
%
MATLAB
Graphics
and
for
his
contribution
of
new
functionality
.
%
Copyright
2015
-
2016
The
MathWorks
,
Inc
.
%
set
source
if
nargin
<
2
hTarget
=
hThis
.
Target
(
1
);
end
%
create
a
Data
Cursor
if
isTargetAxes
(
hThis
)
%
target
is
an
axes:
create
a
dummy
line
handle
hDummyLineHandle
=
line
(
0
,
0
,
'
Parent
'
,
hThis
.
GroupHandle
,
...
'
Visible
','
off
'
,
'
HandleVisibility
','
off
'
,
'
Clipping
','
off
'
,...
'
PickableParts
','
none
'
,
'
HitTest
','
off
'
,
'
Interruptible
','
off
'
);
hThis
.
DataCursorDummyTargetHandle
=
matlab
.
graphics
.
chart
.
primitive
.
Line
(
hDummyLineHandle
);
%
hNewDataCursor
=
matlab
.
graphics
.
shape
.
internal
.
PointDataCursor
(
hThis
.
DataCursorDummyTargetHandle
);
elseif
isTargetChart
(
hThis
)
%
target
is
a
chart:
create
a
direct
point
data
cursor
try
%
create
directly
hNewDataCursor
=
matlab
.
graphics
.
shape
.
internal
.
PointDataCursor
(
hTarget
);
catch
%
probably
,
not
a
DataAnnotatable
(
matlab
.
graphics
.
chart
.
interaction
.
DataAnnotatable
)
try
%
create
via
datacursormode
hDataCursorMode
=
datacursormode
();
hDataTip
=
hDataCursorMode
.
createDatatip
(
hTarget
);
%
hNewDataCursor
=
hDataTip
.
Cursor
;
%
delete
(
hDataTip
);
%
it
'
s
services
are
no
longer
required
hDataCursorMode
.
Enable
=
'
off
'
;
%
disable
data
cursor
mode
catch
%
throw
error
error
(
message
(
'
MATLAB:cursorbar:
InvalidTarget
'
));
end
end
else
%
throw
error
error
(
message
(
'
MATLAB:cursorbar:
InvalidTarget
'
));
end
%
delete
old
handle
hOldDataCursor
=
hThis
.
DataCursorHandle
;
delete
(
hOldDataCursor
);
%
update
old
handle
hThis
.
DataCursorHandle
=
hNewDataCursor
;
Event Timeline
Log In to Comment