Passing points from 'enterPath' to 'changeEnterFun'

Discussion in 'Cadence' started by Suresh Jeevanandam, Oct 9, 2004.

  1. Hi andrew and all,
    I have a function which calls 'enterPath' and has an associated options
    form. When the values in the options form updated, I want the rubberBand
    outlines also get updated. How should the callback function for these
    entry-fields in the options form be defined. Should I call
    changeEnterFun inside that. If so, how should I pass the points that are
    already entered? ...using a temporary variable??

    Or can I do this without using changeEnterFun...

    Andrew, Could you please post if you have written some sharable code
    that uses enterfunction and gets updated from the options form..

    thanks.

    Regards,
    Suresh
     
    Suresh Jeevanandam, Oct 9, 2004
    #1
  2. Hi Suresh,

    Apologies for the delay - I've been travelling rather a lot recently,
    and didn't have an example to hand, so had to wait for a free moment
    to put something together.

    Below is an example of doing exactly what you ask for, if I've
    understood you properly. I think I'll write this up as a solution for
    sourcelink as it seems like a useful illustration.

    Best Regards,

    Andrew.

    ;------------------------------------------------------------------------
    ; Example of changing an enter function. The main entry point
    ; in this example is ABenterPath()
    ;
    ; The code works by maintaining a property, pointList, on the options
    ; form, which contains the current list of points. Then when the
    ; enter function is changed (to change the path width, say), it can
    ; pass the current point list to the new enter function
    ;------------------------------------------------------------------------

    ;------------------------------------------------------------------------
    ; Create the options form for the command
    ;------------------------------------------------------------------------
    procedure(ABcreatePathForm()
    let((width)
    width=hiCreateFloatField(
    ?name 'width
    ?value 1.0
    ?prompt "Width"
    ?callback "ABchangePathWidth(hiGetCurrentForm())"
    )
    hiCreateAppForm(
    ?name 'ABpathForm
    ?formTitle "Path Form"
    ?formType 'options
    ?buttonLayout 'HideCancel
    ?fields list((list width 0:0 400:30 100))
    )
    )
    )

    procedure(ABchangePathWidth(form)

    ;--------------------------------------------------------------------
    ; When the width is changed on the options form, change
    ; the enter function to be a new enterPath, with the same
    ; arguments as before (passing the updated width), but
    ; also passing the list of points that was collected in the
    ; addPointProc and delPointProc callbacks

    ;--------------------------------------------------------------------
    changeEnterFun(
    'enterPath
    ?prompts '("Enter points")
    ?pathWidth form->width->value
    ?points form->pointList
    ?doneProc "ABfinishPath"
    ?addPointProc "ABpathAddPoint"
    ?delPointProc "ABpathDelPoint"
    ?form ABpathForm
    )
    )

    procedure(ABenterPath()

    ;--------------------------------------------------------------------
    ; Create the options form if it doesn't exist already

    ;--------------------------------------------------------------------
    unless(boundp('ABpathForm)
    ABcreatePathForm()
    )

    ;--------------------------------------------------------------------
    ; And then start off the enterPath. May get changed later on
    ; if the path width is changed on the options form

    ;--------------------------------------------------------------------
    enterPath(
    ?prompts '("Enter points")
    ?pathWidth ABpathForm->width->value
    ?doneProc "ABfinishPath"
    ?addPointProc "ABpathAddPoint"
    ?delPointProc "ABpathDelPoint"
    ?form ABpathForm
    )
    )

    procedure(ABfinishPath(_win done pts)

    ;--------------------------------------------------------------------
    ; The doneProc gets invoked when the changeEnterFun
    ; is done, but with done set to nil. It's like cancelling
    ; the old enter function, and then starting a new one

    ;--------------------------------------------------------------------
    when(done
    printf("Points entered %L\n" pts)
    )
    )

    ;------------------------------------------------------------------------
    ; The next two functions are used to maintain the list of points
    ; so that when a changeEnterFun is done, we know which points
    ; to initialise the new enterFun instance with
    ;------------------------------------------------------------------------

    procedure(ABpathAddPoint(_win points)
    ABpathForm->pointList=points
    )

    procedure(ABpathDelPoint(_win points)

    ;--------------------------------------------------------------------
    ; Use destructive operators to knock off the last point in
    ; the list. The delPointProc gets passed the list just before
    ; the point gets removed

    ;--------------------------------------------------------------------
    if(cdr(points) then
    foreach(maplist sublist points
    unless(cddr(sublist) rplacd(sublist nil))
    )
    else
    points=nil
    ) ; if
    ABpathForm->pointList=points
    )
     
    Andrew Beckett, Oct 13, 2004
    #2
  3. Andrew,
    Thanks.


    In the function definition of ABchangePathWidth, do we really need the
    form parameter, because I think it is going to get the same form
    (ABpathForm) every time. Am I missing something?
    I wish we had the ?delPointProc call back called with the modified point
    list. Is there any purpose behind this behavior?
    [...]

    One more question. Is there a way to create user defined rubberBand
    outlines for enter functions. For example, the leHiCreatePath form
    allows users jump to next metal level with an option to create contacts,
    and when the user tries to locate the contact the rubberband outlines
    are displayed.

    If I want to do a little variant of this, is there a way to create these
    outlines and they would follow the mouse movement.

    Thanks again.

    Regards,
    Suresh
     
    Suresh Jeevanandam, Oct 14, 2004
    #3
  4. Hi Suresh,

    No, we don't. The global variable could be used.

    It's actually that way because I initially accidentally declared the
    function as the form callback rather than a field callback. Just a
    mistake on my part.

    That said, it's not bad practice, because you may want to extend the
    idea to allow multiple invocations of the tool with unique forms for
    each invocation - but I didn't do that.

    So you're not missing something - I just decided to pass the form
    this way.

    Andrew.
     
    Andrew Beckett, Oct 14, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.