• 用mel编写自定义节点的属性编辑器界面


    用mel编写自定义节点的属性编辑器界面比较麻烦,而且网上例子又少,下面给出一个范例,说明基本的格式
    1. // 初始化节点时调用
    2. global proc initControl(string $attrName)
    3. {
    4. // 传进来的参数是节点属性名,使用这个方法获得节点名称
    5. string $nodeName = `plugNode $attrName`;
    6. setUITemplate -pst "attributeEditorTemplate";
    7. button -label "Compute Weight" -c ("cageDeform -init -name " + $nodeName) computeWeightButton;
    8. setUITemplate -ppt;
    9. }
    10. // 修改节点时(例如点击另一个同类节点)调用
    11. // 此函数的目的是对按钮绑定的命令做相应修改,使其能应用于相应节点
    12. global proc modifyControl(string $attrName)
    13. {
    14.   // 当attrName = “cageDeformer1.noAttr”
    15. // plugNode 命令能够提取节点名字cageDeformer1
    16. string $nodeName = `plugNode $attrName`;
    17. print $nodeName;
    18. button -e -c ("meshControl -init -name " + $nodeName) computeWeightButton;
    19. }
    20. // 函数名同文件名一样,同节点名cageDeformer对应
    21. global proc AEcageDeformerTemplate(string $nodeName)
    22. {
    23. editorTemplate -beginScrollLayout;
    24.         // 新建一个卷展栏
    25. editorTemplate -beginLayout "Weight Scheme" -collapse false;
    26. // addControl自动指定合适类型的控件
    27. editorTemplate -addControl "maxNeighbourNum";
    28. editorTemplate -addControl "weightPower";
    29.          // 在指定的时机调用前面的函数
    30. editorTemplate -callCustom "initControl" "modifyControl" "noAttr";
    31. editorTemplate -endLayout;
    32. editorTemplate -suppress "outMesh";
    33. editorTemplate -suppress "inControlMesh";
    34. editorTemplate -suppress "refMesh";
    35. editorTemplate -suppress "refControlMesh";
    36. editorTemplate -beginLayout "Node Behavior" -collapse true;
    37. editorTemplate -addControl "nodeState";
    38. editorTemplate -addControl "caching";
    39. editorTemplate -endLayout;
    40. editorTemplate -addExtraControls;
    41. editorTemplate -endScrollLayout;
    42. }

    下面是-callCustom的文档解释

    Specifies that at this point in the template when building the dialog, the procedure specified by the first argument is to be called to create some UI objects when a new node type is edited. The procedure specified by the second argument is to be called if an attribute editor already exists and another node of the same type is now to be edited. The replacing procedure should connect any controls created by the creating procedure to the equivalent attributes in the new node. A list of zero or more attributes specifies the attributes which the two procedures will involve. The procedures should have the signature:
    proc AEcustomNew(string attributeName1, string attributeName2)
    
    The number of attributes specified in the call should correspond to the number of attributes in the procedure signature.
     




  • 相关阅读:
    一步一步实现自己的模拟控件(4)——根控件
    一步一步实现自己的模拟控件(6)——控件树及控件区域
    ATL COM初探(1)
    一步一步实现自己的模拟控件(2)——窗口过程thunk
    一步一步实现自己的模拟控件(3)——Widget驱动
    关于硬盘的一些知识
    Win32中TreeView控件的使用方法,类似于资源管理器中文件树形显示方式
    笔记本双系统XP与Ubuntu,重装XP后如何恢复grup引导,另附操作系统启动过程
    vim常用命令
    MFC中CListCtrl控件的使用方法
  • 原文地址:https://www.cnblogs.com/dydx/p/4286746.html
Copyright © 2020-2023  润新知