Axis Designations in SetMarquee Operation

The GetMarquee operation allows us to use axis designations (e.g. left, top) to specify the relative settings for the return coordinates. The SetMarquee operation has no equivalent.

I have a window with an image above using left, top and a graph below using its own axes (e.g. hleft, hbottom). I would like to regenerate a previously drawn marquee with SetMarquee based on coordinates returned from GetMarquee relative to (left, top) rather than relative to the entire window.

The feature request is therefore to allow this type of language.

SetMarquee/W=.../A=(left/right axis, top/bottom axis) left, top, right, bottom


Update: it seems like the following approach works (until this wish is granted). In an earlier version of this post, the code didn't work because I wasn't converting from pixel coordinates to point coordinates.


function setMarqueeByAx(winN,vertAxN,vertBottom,vertTop,horAxN,horLeft,horRight)
    String vertAxN,horAxN,winN
    Variable vertBottom,vertTop,horLeft,horRight
    if (strlen(winN) < 1)
    if (strlen(vertAxN) < 1)
        vertAxN = "left"
    if (strlen(horAxN) < 1)
        horAxN = "bottom"
    getwindow $winN, psizeDC
    Variable pixHorRange = V_right-V_left
    getwindow $winN, psize
    Variable pntsHorRange = V_right-V_left  
    Variable pntsPerPix = pntsHorRange / pixHorRange  //ratio seems to always be equal for vertical, so just using horizontal for calculation of the conversion factor
    Variable bottom=pixelFromAxisVal(winN,vertAxN,vertBottom)*pntsPerPix
    Variable top=pixelFromAxisVal(winN,vertAxN,vertTop)*pntsPerPix
    Variable left=pixelFromAxisVal(winN,horAxN,horLeft)*pntsPerPix
    Variable right=pixelFromAxisVal(winN,horAxN,horRight)*pntsPerPix
    SetMarquee/W=$winN left, top, right, bottom


In reply to by gsb

gsb wrote:

Update: it seems like the following approach works (until this wish is granted). In an earlier version of this post, the code didn't work because I wasn't converting from pixel coordinates to point coordinates.

Thanks. I am using a structure and a function call to populate either marquee or drawing coordinates.

// structure to collect marquee or hRoI coordinates
Structure MarqueeCoordinates
    variable hasmarquee
    variable hasdrawing
    variable paleft
    variable paright
    variable patop
    variable pabottom
    variable pgleft
    variable pgright
    variable pgtop
    variable pgbottom

// fill the structure
Function GetMCCoordinates(mc)
    Struct MarqueeCoordinates &mc
    mc.hasmarquee = v_flag
    DrawAction/W=$k_graphName/L=ProgFront getgroup=hRoI, extractOutline
    mc.hasdrawing = v_flag
    variable pntsh, pxlsh, pntsppxl

    // hRoI drawing overrides marquee
    if (mc.hasdrawing == 1)
        wave w_polyx, w_polyy
        getwindow $k_graphName, psizeDC
        pxlsh = V_right-V_left
        getwindow $k_graphName, psize
        pntsh = V_right-V_left  
        pntsppxl = pntsh / pxlsh
        mc.paleft = PixelFromAxisVal(k_graphName,"left",mc.pgleft)*pntsppxl
        mc.patop = PixelFromAxisVal(k_graphName,"top",mc.pgtop)*pntsppxl
        mc.paright = PixelFromAxisVal(k_graphName,"left",mc.pgright)*pntsppxl
        mc.pabottom = PixelFromAxisVal(k_graphName,"top",mc.pgbottom)*pntsppxl
        killwaves/Z w_polyx, w_polyy
        return 0
    // no hRoI drawing or marquee
    if (mc.hasmarquee == 0)
        mc.paleft = NaN; mc.patop = NaN; mc.paright = NaN; mc.pabottom = NaN
        mc.pgleft = NaN; mc.pgtop = NaN; mc.pgright = NaN; mc.pgbottom = NaN
        return 0
    // marquee
    mc.paleft = v_left
    mc.paright = v_right
    mc.patop = v_top
    mc.pabottom = v_bottom 
    GetMarquee/W=$k_graphName/Z left,top
    mc.pgleft = v_left
    mc.pgright = v_right
    mc.pgtop = v_top
    mc.pgbottom = v_bottom 
    return 0

I can draw a marquee on an image to restrict a histogram region. I need the graph coordinates to compute the image mask. I can get those and the absolute coordinates from the GetMarquee operation. As needed, I lock down the RoI as a drawing (hRoI). For this function, I also need the graph coordinates. When all is done, I can clear the RoI drawing. I want to restore the marquee to those coordinates. But I need the absolute coordinates to do a SetMarquee. Unfortunately ... :-( ... , the extractOutline flag pulls the drawing using graph coordinates, not absolute coordinates.

Hence, the desire to have SetMarquee be aware of placements in graph coordinates as (most) other operations also are.

Jeff- I have just implemented in Igor 9:

SetMarquee/HAX=axisname/VAX=axisname left, top, right, bottom

Using separate flags allows you to mix points and axis coordinates. That might or might not be particularly useful, but seems to me that unnecessary restrictions will only generate future enhancement requests :)

John: Thanks. I would have thought with one flag to handle the independent option with star or blank ...

/AX=(left,*)   ... or ...  /AX=(left,)   // set vertical on the axis titled left and horizontal as absolute top/bottom

/AX=(*,*) ... or ... /AX=()   // clear all axes designations (set to absolute)