Home > Community > Forums > Custom IC SKILL > hiCreateTreeItem

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 hiCreateTreeItem 

Last post Mon, Jul 1 2013 7:03 AM by Andrew Beckett. 6 replies.
Started by skillseeker 25 Jun 2013 01:06 PM. Topic has 6 replies and 820 views
Page 1 of 1 (7 items)
Sort Posts:
  • Tue, Jun 25 2013 1:06 PM

    hiCreateTreeItem Reply

     I am trying to figure out how to insert a dropdown list and also a subTree for a particular item on the tree.

    Here is my sample code that i have taken from the forum website and changed it to map my names..

     

    For TD_DIGITAL i want a subtree just like TD_CORE. How can i achieve this. If there are any alternatives not to use the Tree commands let me know as well. Thanks in advance.

     

    ;;----------------------------------------------------------------------------------------------

     indexTree=hiCreateTree('index)
    ; create two tree items and append them to the root tree
    dow=hiCreateTreeItem('dow list("TD_CORE"))
    hiTreeAppendItem(indexTree dow)
    ; create two sub-trees
    dowTree=hiCreateTree('dows)
    ; put the two sub-trees into the two items created earlier
    hiItemInsertTree(dow dowTree)
    ; add a few leaves for the dowTree and nasTree
    hiTreeAppendItem(dowTree hiCreateTreeItem('cdn list("TD_DIGITAL" "XTD_DIGITAL" "verilog wreal veriloga schematic" "verilog")))
    hiTreeAppendItem(dowTree hiCreateTreeItem('ibm list("VIO_SWITCH" "XVIO_SWITCH" "verilog wreal veriloga verilogams schematic" "wreal")))
    hiTreeAppendItem(dowTree hiCreateTreeItem('rx list("RX" "XRX" "verilog wreal veriloga verilogams schematic" "schematic")))
    hiTreeAppendItem(dowTree hiCreateTreeItem('ls list("TD_LS_CTRL" "XTD_LS_CTRL" "verilog wreal veriloga verilogams schematic" "schematic")))
    hiTreeAppendItem(dowTree hiCreateTreeItem('bk list("BUCK" "XBUCK" "verilog wreal veriloga verilogams schematic" "veriloga")))
    hiTreeAppendItem(dowTree hiCreateTreeItem('bo list("BOOST_3P0V" "XBOOST_3P0V" "verilog wreal veriloga verilogams schematic" "wreal")))

    ;hiTreeAppendItem(nasTree hiCreateTreeItem('orcl list("Oracle" 28.925 5 "Strong Sell")))
    ; create callback, which is called whenever any tree items are selected and which
    ; prints the selected item’s description
    procedure( treeCB(name itemSymList)
       let(()
           while(itemSymList
                itemSym=car(itemSymList)
                println(hiGetTreeItemDescription(eval(itemSym)))
                itemSymList=cdr(itemSymList)
           )
       )
    )



    ; create tree table and use indexTree as the value for ?choice
    treeField = hiCreateTreeTable(
    ?name 'treeField
    ?title "TD_CORE"
    ?titleAlignment 'center
    ?headers list(list("CellName" 125 'left 'string)
    list("instName" 125 'left 'string)
    list("views" 250 'center 'string)
    list("view" 125 'right 'string)
    )
    ?choice indexTree
    ?callback "treeCB"
    )
    ; create a form
    form = hiCreateAppForm(
    ?name 'form
    ?formTitle "MakeFile Configurator"
    ?fields list(
    list(treeField 5:5 900:450 55)
    )
    ?initialSize 500:750)
    hiDisplayForm(form)

     

     

     

     

     

    Thanks

    Devender

    • Post Points: 20
  • Tue, Jun 25 2013 10:07 PM

    Re: hiCreateTreeItem Reply

    Davender,

    I wasn't 100% sure what you wanted, but I modified your example above (probably wise to change the variable names, since they are not exactly meaningful). I've put in bold the bits I changed. I also changed the tree callback from treeCB to MYtreeCB as this clashes with a Cadence function which unfortunately has had the prefix omitted (I've filed a CCR to get that fixed).

    I also added a context menu - you mentioned a "dropdown list" - wasn't sure if that is what you wanted either.

    ;;----------------------------------------------------------------------------------------------

    ; example of adding a context menu
    hiCreateSimpleMenu('MYcontextMenu "Context Menu" list("Item 1" "Item 2") list("println('item1)" "println('item2)"))

     indexTree=hiCreateTree('index)
    ; create two tree items and append them to the root tree
    dow=hiCreateTreeItem('dow list("TD_CORE"))
    hiTreeAppendItem(indexTree dow)
    ; create two sub-trees
    dowTree=hiCreateTree('dows)
    ; put the two sub-trees into the two items created earlier
    hiItemInsertTree(dow dowTree)
    TdDigitalTree=hiCreateTree('TdDigitalTree)
    TdDigitalTreeItem=hiCreateTreeItem('TdDigitalTreeItem list("TD_DIGITAL"))
    hiItemInsertTree(TdDigitalTreeItem TdDigitalTree)
    hiTreeAppendItem(dowTree TdDigitalTreeItem)
    ; add a few leaves for the dowTree and nasTree
    hiTreeAppendItem(TdDigitalTree hiCreateTreeItem('cdn list("TD_DIGITAL" "XTD_DIGITAL" "verilog wreal veriloga schematic" "verilog")))

    hiTreeAppendItem(dowTree hiCreateTreeItem('ibm list("VIO_SWITCH" "XVIO_SWITCH" "verilog wreal veriloga verilogams schematic" "wreal")))
    hiTreeAppendItem(dowTree hiCreateTreeItem('rx list("RX" "XRX" "verilog wreal veriloga verilogams schematic" "schematic")))
    hiTreeAppendItem(dowTree hiCreateTreeItem('ls list("TD_LS_CTRL" "XTD_LS_CTRL" "verilog wreal veriloga verilogams schematic" "schematic")))
    hiTreeAppendItem(dowTree hiCreateTreeItem('bk list("BUCK" "XBUCK" "verilog wreal veriloga verilogams schematic" "veriloga")))
    hiTreeAppendItem(dowTree hiCreateTreeItem('bo list("BOOST_3P0V" "XBOOST_3P0V" "verilog wreal veriloga verilogams schematic" "wreal")))

    ;hiTreeAppendItem(nasTree hiCreateTreeItem('orcl list("Oracle" 28.925 5 "Strong Sell")))
    ; create callback, which is called whenever any tree items are selected and which
    ; prints the selected item¿s description
    procedure( MYtreeCB(name itemSymList)
       let(()
           while(itemSymList
                itemSym=car(itemSymList)
                println(hiGetTreeItemDescription(eval(itemSym)))
                itemSymList=cdr(itemSymList)
           )
       )
    )

    procedure(MYcontextMenuCB(menu form field item)
        printf("Context menu posted for item %L on form field %L\n" item field)
    )



    ; create tree table and use indexTree as the value for ?choice
    treeField = hiCreateTreeTable(
    ?name 'treeField
    ?title "TD_CORE"
    ?titleAlignment 'center
    ?headers list(list("CellName" 125 'left 'string)
    list("instName" 125 'left 'string)
    list("views" 250 'center 'string)
    list("view" 125 'right 'string)
    )
    ?choice indexTree
    ?callback "MYtreeCB"
    )
    ; create a form
    form = hiCreateAppForm(
    ?name 'form
    ?formTitle "MakeFile Configurator"
    ?fields list(
    list(treeField 5:5 900:450 55)
    )
    ?initialSize 500:750)

    form->treeField->hiContextMenu=MYcontextMenu
    form->treeField->hiShowContextMenuCallback='MYcontextMenuCB

    hiDisplayForm(form)

    Best Regards,

    Andrew

    • Post Points: 20
  • Wed, Jun 26 2013 8:56 AM

    Re: hiCreateTreeItem Reply
    Thanks Andrew. Exactly what i was wanting to do create Tree Structures underneath a tree structure. I also want to be able to edit the hiCreateTreeItem values dynamically in the form. Is this possible.
    • Post Points: 20
  • Wed, Jun 26 2013 9:17 AM

    Re: hiCreateTreeItem Reply

    Yes, that's possible.

    Andrew.

    • Post Points: 35
  • Wed, Jun 26 2013 9:36 AM

    Re: hiCreateTreeItem Reply

    Thanks Andrew. Can you point me to an example of how this can be done. Do i add this as an option when i am creating an item "hiCreateTreeItem" or is this option needs to be enabled when creating the TreeTable.

    • Post Points: 5
  • Wed, Jun 26 2013 2:58 PM

    Re: hiCreateTreeItem Reply

    Thanks Andrew.

     

    hiTreeAppendItem(dowTree hiCreateTreeItem('ls list("TD_LS_CTRL" "XTD_LS_CTRL" "verilog wreal veriloga verilogams schematic" "schematic")))

    In this case on the menu if the user wants to change it from"schematic" to "schematic_edited" how can this be achieved.

     

    hiCreateTreeItem does not have an editable option.  Appreciate if you can throw your idea on this.

    • Post Points: 20
  • Mon, Jul 1 2013 7:03 AM

    Re: hiCreateTreeItem Reply

    If you want to be able to change it - one possibility is to have a type in field on the form which gets populated when you click on the item - and then you could type in that field to update it. There isn't a means of directly editing entries in the tree.

    I don't have any good examples of dynamically changing tree forms (well I do, but I can't really post them because they're deeply embedded in other applications). In general it's just about calling the same functions based on (say) an expand callback.

    Here's another simple example you might find useful to get some ideas from (written in LISP syntax, but that shouldn't matter);

    /* abTreeExample.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Feb 16, 2010 
    Modified   
    By         
    
    ***************************************************
    
    SCCS Info: @(#) abTreeExample.il 02/16/10.11:37:50 1.1
    
    */
    
    /****************************************************************
    *                                                               *
    *                 (abCreateTreeExample shapes)                  *
    *                                                               *
    *    Given a list of db objects (e.g. shapes) create a tree     *
    * representation of the data in a form called abTreeExampleForm *
    *                                                               *
    ****************************************************************/
    
    (defun abCreateTreeExample (shapes)
      (let (tree subTreeLookup (shapeNum 1) objType bBox treeItem
                 select delete info subTree treeField)
        ;--------------------------------------------------------------------
        ; Create a table to store the trees for each type of object encountered
        ;--------------------------------------------------------------------
        (setq subTreeLookup (makeTable 'subTreeLookup nil))
        ;--------------------------------------------------------------------
        ; Then traverse the shapes (doesn't have to just be shapes - any db object
        ; will do) and add an item for each
        ;--------------------------------------------------------------------
        (foreach shape shapes
                 (setq objType (dbGetq shape objType))
                 ;-----------------------------------------------------------
                 ; Find the existing tree, or create a new one
                 ;-----------------------------------------------------------
                 (setq subTree 
                       (or 
                         (arrayref subTreeLookup objType)
                         (setarray subTreeLookup objType
                                   (hiCreateTree (concat objType 'tree))
                                   )
                         ))
                 (setq bBox (dbGetq shape bBox))
                 ;-----------------------------------------------------------
                 ; Add an item to the appropriate shape tree for this
                 ; object
                 ;-----------------------------------------------------------
                 (hiTreeAppendItem
                   subTree
                   (hiCreateTreeItem (concat 'shape shapeNum)
                                     (list (sprintf nil "Shape %d" shapeNum)
                                           (dbGetq shape layerName)
                                           (dbGetq shape purpose)
                                           (xCoord (lowerLeft bBox))
                                           (yCoord (lowerLeft bBox))
                                           (xCoord (upperRight bBox))
                                           (yCoord (upperRight bBox))
                                           )
                                     )
                   )
                 (postincrement shapeNum)
                 )
        ;--------------------------------------------------------------------
        ; Now create the main tree
        ;--------------------------------------------------------------------
        (setq tree (hiCreateTree 'shapes))
        (foreach shapeType subTreeLookup
                 (setq treeItem
                   (hiCreateTreeItem 
                     (concat shapeType)
                     (list shapeType)
                     )
                   )
                 (hiTreeAppendItem shapes treeItem)
                 (hiItemInsertTree treeItem (arrayref subTreeLookup shapeType))
                 )
        ;--------------------------------------------------------------------
        ; And the tree field itself
        ;--------------------------------------------------------------------
        (setq treeField
              (hiCreateTreeTable
                ?name 'shapeTree
                ?title "Shapes"
                ?titleAlignment 'center
                ?headers (list
                           (list "Type" 125 'left 'string t)
                           (list "Layer" 80 'left 'string t)
                           (list "Purpose" 80 'left 'string t)
                           (list "LLX" 80 'left 'float t)
                           (list "LLY" 80 'left 'float t)
                           (list "URX" 80 'left 'float t)
                           (list "URY" 80 'left 'float t)
                           )
                ?choice tree
                )
              )
        ;--------------------------------------------------------------------
        ; Now create the context menu
        ;--------------------------------------------------------------------
        (setq select
              (hiCreateMenuItem
                ?name 'select
                ?itemText "Select"
                )
              )
        (setq delete
              (hiCreateMenuItem
                ?name 'delete
                ?itemText "Delete"
                )
              )
        (setq info
              (hiCreateMenuItem
                ?name 'info
                ?itemText "Delete"
                )
              )
        (hiCreateMenu
          'abTreeExampleMenu
          "Tree Item"
          (list select delete info)
          )
        ;--------------------------------------------------------------------
        ; Attach the context menu to the field
        ;--------------------------------------------------------------------
        (putpropq treeField abTreeExampleMenu hiContextMenu)
        (putpropq treeField 'abTreeExampleMenuContextCB hiShowContextMenuCallback)
        ;--------------------------------------------------------------------
        ; Then finally create the form
        ;--------------------------------------------------------------------
        (hiCreateAppForm
          ?name 'abTreeExampleForm
          ?formTitle "Tree Example"
          ?fields (list
                    (list treeField 5:5 610:400 20)
                    )
          ?initialSize 620:420
          ?attachmentList (list
                            hicLeftPositionSet|hicRightPositionSet|
                            hicTopPositionSet|hicBottomPositionSet
                            )
          ) ; hiCreateAppForm
        ) ; let
      ) ; defun abCreateTreeExampleForm
    
    /***************************************************************
    *                                                              *
    *      (abTreeExampleMenuContextCB menu form field item)       *
    *                                                              *
    *                Callback for the context menu                 *
    *                                                              *
    ***************************************************************/
    
    (defun abTreeExampleMenuContextCB (menu form field item)
      (printf "Context Menu called: %L %L %L %L\n"
              menu form field item)
      (printf "Value of tree is %L\n"
              (getq (get form field) value))
      )
    
    /***************************************************************
    *                                                              *
    *                   (abTreeExample objects)                    *
    *                                                              *
    *                       Main entry point                       *
    *                                                              *
    ***************************************************************/
    
    (defun abTreeExample (objects)
      (abCreateTreeExample objects)
      (hiDisplayForm abTreeExampleForm)
      )
     

     

    • Post Points: 5
Page 1 of 1 (7 items)
Sort Posts:
Started by skillseeker at 25 Jun 2013 01:06 PM. Topic has 6 replies.