Code Monkey home page Code Monkey logo

Comments (10)

OfekShilon avatar OfekShilon commented on August 22, 2024 2

@RayInos thanks for the great find! How did you discover these private functions?
Two slight improvements, one to eliminate a deprecation warning and one to slightly improve performance:

persistent convertDataSpaceCoordsToViewerCoords;

if verLessThan('matlab','8.4.0')
    xvert = local_Data2PixelTransform(ax,vert)';
    xcp = local_Data2PixelTransform(ax,cp')';
else
    if isempty(convertDataSpaceCoordsToViewerCoords)
        convertDataSpaceCoordsToViewerCoords = specgraphhelper('convertDataSpaceCoordsToViewerCoords');
    end

    xvert = convertDataSpaceCoordsToViewerCoords(axchild, vert');
    xcp = convertDataSpaceCoordsToViewerCoords(ax, cp);
end

from mrtools.

RayInos avatar RayInos commented on August 22, 2024 1

Hey everybody!

Since I was eager to get the select3d method working for mouse movement, the hit event didn't help a lot. Through some reverse engineering I found a Matlab intern function doing the job perfectly all right.

Replacing
% Transform vertices from data space to pixel space
xvert = local_Data2PixelTransform(ax,vert)';
xcp = local_Data2PixelTransform(ax,cp')';
with
% Transform vertices from data space to pixel space (fixed for Matlab>M14b)
if ~graphicsversion(get(ax,'Parent'),'handlegraphics')
xvert = specgraphhelper('convertDataSpaceCoordsToViewerCoords', axchild, vert');
xcp = specgraphhelper('convertDataSpaceCoordsToViewerCoords', ax, cp);
else
xvert = local_Data2PixelTransform(ax,vert)';
xcp = local_Data2PixelTransform(ax,cp')';
end
should work perfectly all right (tested with linear axes and DataAspectRatio=1).

One might change the condition ~graphicsversion(get(ax,'Parent'),'handlegraphics') to something more elegant. This code line assumes the axes object ax is direct child to the figure (which fits in my case). An alternative might be checking the matlab version with ~verLessThan('matlab','8.4'), since the graphics update came in 8.4 (R14b).

Note, that the transposition of vert and cp in the arguments of specgraphhelper(...) is crucial to the result. Transposing one of them leads to wrong results.

Happy selecting!
Ray

from mrtools.

justingardner avatar justingardner commented on August 22, 2024

Ugh. I was always worried about functions like this that people grab off of the Mathoworks site. Once they stop working there is no recourse since you don’t know how they work, they are poorly documented and you can’t fix what is likely a simple fix. If you have any ideas, let me know. I may get to it at some point, but can live with defining ROIs on surfaces and anatomy images if all else fails….

-j.

On Mar 30, 2015, at 3:44 AM, Denis Schluppeck [email protected] wrote:

yay! another matlab upgrade problem. the function select3d() can't access the undocumented axis properties on lines 329 onwards.

Happens when a surface is loaded as base and mrInterrogator running (on mouseMoveHandler() events).

xform = get(ax,'x_RenderTransform');
offset = get(ax,'x_RenderOffset');
scale = get(ax,'x_RenderScale');
These properties got deprecated in latest release. It doesn't look like there's an obvious fix but the same info might be (apparently?) wrapped up inside a property called DataSpace. Still need to check this.

http://undocumentedmatlab.com/blog/customizing-axes-part-4-additional-properties` http://undocumentedmatlab.com/blog/customizing-axes-part-4-additional-properties%60

Reply to this email directly or view it on GitHub #25.

from mrtools.

schluppeck avatar schluppeck commented on August 22, 2024

yes - ugh. Completely agree. Maybe a solution is to wrap select3d() with something like mlrSelect3d() as per mlrFullCrosshair() and do a matlab version check there, disabling selection on surfaces for ver>8.4 and warning for now. Then it'll be transparent later on, when we have found a fix/replacement for the functionality?

from mrtools.

RayInos avatar RayInos commented on August 22, 2024

Hey together. I had the same problem in another project. I replaced the code by what came to my mind first:
xform = view;
offset = [0 0 0];
scale = [1 1 1];
That works fine, YET. I have not tested it very long. Hopefully, it helps you, too, or gives a hint for a better replacement.

from mrtools.

justingardner avatar justingardner commented on August 22, 2024

Thanks Raylnos, but I'm not sure that will work - that makes the code not crash, but it is not the right view xform, offset and scale so probably won't return the correct point. This comment from a user on the "undocumentedmatlab" forum looks promising though (suggest that we can get rid of select3d and use matlab features:

Konstantin Alexeev says:
May 7, 2015 at 5:14 am
Hello Yair,

I used the select3d tool from matlab file exchange to find, where the mouse clicked on 3d, surface. Since matlab 2014, the select3d function seems to don’t work anymore because, “x_RenderTransform” and other propertiese were removed.

However, now the matlab provides the coordinates of the section of mouse point and the surface as the second parameter of the surface callback.

K>> varargin{2}

ans =

Hit with properties:

Button: 1
IntersectionPoint: [20.8219 16.8589 20.7370]
Source: [1x1 Surface]
EventName: ‘Hit’

from mrtools.

justingardner avatar justingardner commented on August 22, 2024

Just put in a fix for this in the latest commit. Used callbacks on the surfaces (see comment above) which in the latest matlab returns the "IntersectionPoint" above which tells you where the user clicked. Could not find a way to do mouseMoves (since the callback MouseDown is the only one that seems to be implemented by mathwork).

from mrtools.

jonatmudd avatar jonatmudd commented on August 22, 2024

@OfekShilon @RayInos
Heaps of thanks for this fix! Works great for me (and would have never sorted this without your help.
Cheers, Jon

from mrtools.

fernandozucatelli avatar fernandozucatelli commented on August 22, 2024

OfekShilon's solution does work for MatlabR2017a. Thanks.

from mrtools.

brainwatcher avatar brainwatcher commented on August 22, 2024

Hi, I encounter the error "Undefined function or variable 'specgraphhelper'. " in R2019a when I used select3d. Is there any suggestions to correct this? Thank you. Besides, I found the property of axes "x_RenderTransform" seems not existed. "There is no x_RenderTransform property on the Axes class. "

from mrtools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.