• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. dlDlistToIcon result is not usable in a form

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 143
  • Views 13296
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

dlDlistToIcon result is not usable in a form

caver456
caver456 over 6 years ago

I would like to dynamically update an icon in a form label based on values in other fields of the same form.  This works when loading the icon from an image, but, does not seem to work when creating the icon from a dl (Display List) object - the goal is to draw a simple mock-up stick figure based on other form fields, so, a "Display List" object as a label icon seems to be the way to go, unless there is a better option? 

Both dlDlistToIcon and hiLoadIconFile return the expected (handle x y) triplet, but, the one from the Dlist never draws anything - just a black box.  If I show the dlist in a blank window then it draws as expected - just not in the label icon.


(apologies in advance for asking late afternoon before the holidays, and for not being around to respond again til Jan 2)

The code (omitting the form definition) - the crux is at the very end of the code:

dl=dlMakeDisplayList()
penTable=dlMakePenTable(5)
dlSetPenTable(dl penTable)
colorIndex=hiMatchColor(nameToColor("red"))
dlSetPenColor(1 colorIndex penTable)
dlSetPenFillStyle( 1 "SolidFill" penTable)
dlAddBox(dl 1 list(0 0) list(200 200) 'bigBox)
dlAddBox(dl 4 list(20 20) list(180 180) 'littleBox)

icon=dlDlistToIcon(dl 200 200)

summaryLayout=hiCreateHorizontalBoxLayout('summaryLayout
?frame "Summary"
?margins list(50 20 50 20)
?spacing 50
?items list(
hiCreateFloatField(
?name 'totalWidth
?prompt "Total Width:"
?editable 'nil
)
hiCreateFloatField(
?name 'totalHeight
?prompt "Total Height:"
?editable 'nil
)
hiCreateLabel(
?name 'iconLabel
?labelIcon icon
)
)
)

sep1=hiCreateSeparatorField(?name 'sep1)
sep2=hiCreateSeparatorField(?name 'sep2)

arrayGenTopFrame=hiCreateFormLayout('arrayGenTopFrame
?frame "Top Frame"
?items list(coreLayout sep1 ewLayout nsLayout cornerLayout sep2 summaryLayout)
)

hiCreateLayoutForm('arrayGenForm "arrayGen Compound Array Generator" arrayGenTopFrame
?callback 'arrayGenFormCB
?minSize 800:10
)

procedure(coreLCVCB()
size=getCellSize(
arrayGenForm->arrayGenTopFrame->coreLayout->coreLCVLayout->coreL->value
arrayGenForm->arrayGenTopFrame->coreLayout->coreLCVLayout->coreC->value
arrayGenForm->arrayGenTopFrame->coreLayout->coreLCVLayout->coreV->value
)
arrayGenForm->arrayGenTopFrame->coreLayout->coreWidthLayout->coreCellWidth->value=car(size)
arrayGenForm->arrayGenTopFrame->coreLayout->coreHeightLayout->coreCellHeight->value=cadr(size)
ddsUpdateSyncWithForm()
updateIcon()
)

procedure(updateIcon()
let((lib cell view file w h icon)
lib=arrayGenForm->arrayGenTopFrame->coreLayout->coreLCVLayout->coreL->value
cell=arrayGenForm->arrayGenTopFrame->coreLayout->coreLCVLayout->coreC->value
view=arrayGenForm->arrayGenTopFrame->coreLayout->coreLCVLayout->coreV->value

w=arrayGenForm->arrayGenTopFrame->coreLayout->coreWidthLayout->coreTotalWidth->value
h=arrayGenForm->arrayGenTopFrame->coreLayout->coreHeightLayout->coreTotalHeight->value

; method 1: this does not work - the image stays blank regardless of cell selection
dlClearDisplayList(dl)
dlAddBox(dl 1 list(0 0) list(round(w) round(h)) 'extentBox)
icon=dlDlistToIcon(dl 200 200)
printf("setting icon: %L w=%L h=%L\n" icon w h)
arrayGenForm->arrayGenTopFrame->summaryLayout->iconLabel->labelIcon=icon

; method 2: this works - the image is refreshed every time you select a different cell
; whether you use hiLoadIconFile or hiLoadImageFile
; file=ddGetObj(lib cell view hiGetThumbnailFilename())->readPath
; when(file
; icon=hiLoadIconFile(file 200 200)
; printf("setting icon: %L\n" icon)
; arrayGenForm->arrayGenTopFrame->summaryLayout->iconLabel->value=icon
; )
)
)

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago

    I added some code around it so that I could debug the problem. The issue was in this line:

    arrayGenForm->arrayGenTopFrame->summaryLayout->iconLabel->labelIcon=icon

    It should have been:

    arrayGenForm->arrayGenTopFrame->summaryLayout->iconLabel->value=icon

    Here's the modified code (with the additional fields to help me debug):

    dl=dlMakeDisplayList()
    penTable=dlMakePenTable(5)
    dlSetPenTable(dl penTable)
    colorIndex=hiMatchColor(nameToColor("red"))
    dlSetPenColor(1 colorIndex penTable)
    dlSetPenFillStyle( 1 "SolidFill" penTable)
    dlAddBox(dl 1 list(0 0) list(200 200) 'bigBox)
    dlAddBox(dl 4 list(20 20) list(180 180) 'littleBox)
    /* just checking what the icon would have looked like
    let(((w 50) (h 30))
      dlClearDisplayList(dl)
      dlAddBox(dl 1 list(0 0) list(round(w) round(h)) 'extentBox)
    )
    */
    
    icon=dlDlistToIcon(dl 200 200)
    enterLayout=hiCreateHorizontalBoxLayout('enterLayout
      ?frame "Debug"
      ?margins list(50 20 50 20)
      ?spacing 50
      ?items list(
        hiCreateFloatField(
          ?name 'width
          ?prompt "Width:"
        )
        hiCreateFloatField(
          ?name 'height
          ?prompt "Height:"
        )
        hiCreateButton(
          ?name 'updateIt
          ?buttonText "Update"
          ?callback "updateIcon()"
          )
      )
    )
    
    summaryLayout=hiCreateHorizontalBoxLayout('summaryLayout
      ?frame "Summary"
      ?margins list(50 20 50 20)
      ?spacing 50
      ?items list(
        hiCreateFloatField(
          ?name 'totalWidth
          ?prompt "Total Width:"
          ?editable 'nil
        )
        hiCreateFloatField(
          ?name 'totalHeight
          ?prompt "Total Height:"
          ?editable 'nil
        )
        hiCreateLabel(
          ?name 'iconLabel
          ?labelIcon icon
        )
      )
    )
    
    sep1=hiCreateSeparatorField(?name 'sep1)
    sep2=hiCreateSeparatorField(?name 'sep2)
    
    arrayGenTopFrame=hiCreateFormLayout('arrayGenTopFrame
      ?frame "Top Frame"
    ;?items list(coreLayout sep1 ewLayout nsLayout cornerLayout sep2 summaryLayout)
      ?items list(sep1 enterLayout sep2 summaryLayout)
    )
    
    hiCreateLayoutForm('arrayGenForm "arrayGen Compound Array Generator" arrayGenTopFrame
      ?callback 'arrayGenFormCB
      ?minSize 800:10
    )
    
    procedure(coreLCVCB()
      size=getCellSize(
        arrayGenForm->arrayGenTopFrame->coreLayout->coreLCVLayout->coreL->value
        arrayGenForm->arrayGenTopFrame->coreLayout->coreLCVLayout->coreC->value
        arrayGenForm->arrayGenTopFrame->coreLayout->coreLCVLayout->coreV->value
      )
      arrayGenForm->arrayGenTopFrame->coreLayout->coreWidthLayout->coreCellWidth->value=car(size)
      arrayGenForm->arrayGenTopFrame->coreLayout->coreHeightLayout->coreCellHeight->value=cadr(size)
      ddsUpdateSyncWithForm()
      updateIcon()
    )
    
    procedure(updateIcon()
      let((lib cell view file w h icon)
        /*
        lib=arrayGenForm->arrayGenTopFrame->coreLayout->coreLCVLayout->coreL->value
        cell=arrayGenForm->arrayGenTopFrame->coreLayout->coreLCVLayout->coreC->value
        view=arrayGenForm->arrayGenTopFrame->coreLayout->coreLCVLayout->coreV->value
    
        w=arrayGenForm->arrayGenTopFrame->coreLayout->coreWidthLayout->coreTotalWidth->value
        h=arrayGenForm->arrayGenTopFrame->coreLayout->coreHeightLayout->coreTotalHeight->value
        */
        w=arrayGenForm->width->value
        h=arrayGenForm->height->value
    
        ; method 1: this does not work - the image stays blank regardless of cell selection 
        dlClearDisplayList(dl)
        dlAddBox(dl 1 list(0 0) list(round(w) round(h)) 'extentBox)
        icon=dlDlistToIcon(dl 200 200)
        printf("setting icon: %L w=%L h=%L\n" icon w h)
        ; THIS LINE WAS INCORRECT...
        ;arrayGenForm->arrayGenTopFrame->summaryLayout->iconLabel->labelIcon=icon
        arrayGenForm->arrayGenTopFrame->summaryLayout->iconLabel->value=icon
    
        ; method 2: this works - the image is refreshed every time you select a different cell
        ; whether you use hiLoadIconFile or hiLoadImageFile
        ; file=ddGetObj(lib cell view hiGetThumbnailFilename())->readPath
        ; when(file
        ; icon=hiLoadIconFile(file 200 200)
        ; printf("setting icon: %L\n" icon)
        ; arrayGenForm->arrayGenTopFrame->summaryLayout->iconLabel->value=icon
        ; )
      )
    )
    
    ; to test
    ; hiDisplayForm(arrayGenForm)

    When initially displaying the form, it appears like this (so the display list icon is clearly being used):

    If I enter some values in the Debug fields and hit Update, the form updates:

    Here's a second update:

    So I think it's just down to the statement above. I didn't quite get what  you meant about "just a black box" - for me before this tweak to the code, the icon remained as it did initially (the first image above).

    Merry Christmas and a Happy New Year!

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • caver456
    caver456 over 6 years ago in reply to Andrew Beckett

    Thanks, that works - I thought I had tried that before, but, clearly I had not!

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information