PDA

View Full Version : mel_ui


arunspooja
05-24-2006, 12:57 PM
Good Evening



I have problem in creating the show menu.



The menuItems are working properly but the checkbox is not updating.



I have created a menu to show or not the selected menu item.



When "none" is clicked there should not be any "tick" mark but it is showing tick mark.



I dont know how to update the checkbox depending on the selection.



If any one find the solution kindly reply



When you execute this you can find it clearly



Thank you








if (`window -ex MA_modelingToolsWin`) deleteUI MA_modelingToolsWin;



window -wh 300 600 -menuBar true -title "MODELING_TOOLS" MA_modelingToolsWin;



//------menu bar-----//



menuBarLayout mainmenu;



//-------Show Menu--------------



menu -l "Show" -to 1 -p "mainmenu" showmenu;

menuItem -l "All" -c("show(\"all\");");

menuItem -l "None" -c("show(\"none\");");

menuItem -divider true;

menuItem -checkBox 1 -l "Nurbs Curves" -c("show(\"curves\");");

menuItem -checkBox 1 -l "Nurbs Surfaces" -c("show(\"surfaces\");");

menuItem -checkBox 1 -l "Polygons" -c("show(\"polygons\");");

menuItem -checkBox 1 -l "Subdiv Surfaces" -c("show(\"subdiv\");");

menuItem -checkBox 1 -l "Planes" -c("show(\"planes\");");

menuItem -checkBox 1 -l "Lights" -c("show(\"lights\");");

menuItem -divider true;

menuItem -checkBox 1 -l "Cameras" -c("show(\"cameras\");");

menuItem -checkBox 1 -l "Joints" -c("show(\"joints\");");

menuItem -checkBox 1 -l "IK Handles" -c("show(\"ikhandles\");");

menuItem -checkBox 1 -l "Deformers" -c("show(\"deformers\");");

menuItem -checkBox 1 -l "Dynamics" -c("show(\"dynamics\");");

menuItem -checkBox 1 -l "Fluids" -c("show(\"fluids\");");

menuItem -divider true;

menuItem -checkBox 1 -l "Hair Systems" -c("show(\"hair\");");

menuItem -checkBox 1 -l "Follicles" -c("show(\"follicles\");");

menuItem -checkBox 1 -l "Locators" -c("show(\"locators\");");

menuItem -checkBox 1 -l "Dimensions" -c("show(\"dimensions\");");

menuItem -checkBox 1 -l "Pivots" -c("show(\"pivots\");");

menuItem -checkBox 1 -l "Handles" -c("show(\"handles\");");

menuItem -divider true;

menuItem -checkBox 1 -l "Textures" -c("show(\"textures\");");

menuItem -checkBox 1 -l "Strokes" -c("show(\"strokes\");");

menuItem -checkBox 1 -l "Nurbs CVs" -c("show(\"cv\");");

menuItem -checkBox 1 -l "Nurbs Hulls" -c("show(\"hulls\");");

menuItem -checkBox 1 -l "Grid" -c("show(\"grid\");");

setParent..;

showWindow MA_modelingToolsWin;











//------show Panel--------//



global proc show(string $name)

{

string $panel;

string $type;

int $query;

$panel=`getPanel -up`;

if(""==$panel)

{

$panel=`getPanel -wf`;

}

if(""!=$panel)

{

$type=`getPanel -to $panel`;

if($type=="modelPanel")

{

switch($name)

{

case "curves":

$query=`modelEditor -q -nc $panel`;

if($query)

modelEditor -e -nc 0 $panel;

else

modelEditor -e -nc 1 $panel;

break;

case "surfaces":

$query=`modelEditor -q -ns $panel`;

if($query)

modelEditor -e -ns 0 $panel;

else

modelEditor -e -ns 1 $panel;

break;

case "polygons":

$query=`modelEditor -q -pm $panel`;

if($query)

modelEditor -e -pm 0 $panel;

else

modelEditor -e -pm 1 $panel;

break;

case "subdiv":

$query=`modelEditor -q -sds $panel`;

if($query)

modelEditor -e -sds 0 $panel;

else

modelEditor -e -sds 1 $panel;

break;

case "planes":

$query=`modelEditor -q -pl $panel`;

if($query)

modelEditor -e -pl 0 $panel;

else

modelEditor -e -pl 1 $panel;

break;

case "lights":

$query=`modelEditor -q -lt $panel`;

if($query)

modelEditor -e -lt 0 $panel;

else

modelEditor -e -lt 1 $panel;

break;

case "cameras":

$query=`modelEditor -q -ca $panel`;

if($query)

modelEditor -e -ca 0 $panel;

else

modelEditor -e -ca 1 $panel;

break;

case "joints":

$query=`modelEditor -q -j $panel`;

if($query)

modelEditor -e -j 0 $panel;

else

modelEditor -e -j 1 $panel;

break;

case "ikhandles":

$query=`modelEditor -q -ikh $panel`;

if($query)

modelEditor -e -ikh 0 $panel;

else

modelEditor -e -ikh 1 $panel;

break;

case "deformers":

$query=`modelEditor -q -df $panel`;

if($query)

modelEditor -e -df 0 $panel;

else

modelEditor -e -df 1 $panel;

break;

case "dynamics":

$query=`modelEditor -q -dy $panel`;

if($query)

modelEditor -e -dy 0 $panel;

else

modelEditor -e -dy 1 $panel;

break;

case "fluids":

$query=`modelEditor -q -fl $panel`;

if($query)

modelEditor -e -fl 0 $panel;

else

modelEditor -e -fl 1 $panel;

break;

case "hair":

$query=`modelEditor -q -hs $panel`;

if($query)

modelEditor -e -hs 0 $panel;

else

modelEditor -e -hs 1 $panel;

break;

case "follicles":

$query=`modelEditor -q -fo $panel`;

if($query)

modelEditor -e -fo 0 $panel;

else

modelEditor -e -fo 1 $panel;

break;

case "locators":

$query=`modelEditor -q -lc $panel`;

if($query)

modelEditor -e -lc 0 $panel;

else

modelEditor -e -lc 1 $panel;

break;

case "dimensions":

$query=`modelEditor -q -dim $panel`;

if($query)

modelEditor -e -dim 0 $panel;

else

modelEditor -e -dim 1 $panel;

break;

case "pivots":

$query=`modelEditor -q -pv $panel`;

if($query)

modelEditor -e -pv 0 $panel;

else

modelEditor -e -pv 1 $panel;

break;

case "handles":

$query=`modelEditor -q -ha $panel`;

if($query)

modelEditor -e -ha 0 $panel;

else

modelEditor -e -ha 1 $panel;

break;

case "textures":

$query=`modelEditor -q -tx $panel`;

if($query)

modelEditor -e -tx 0 $panel;

else

modelEditor -e -tx 1 $panel;

break;

case "strokes":

$query=`modelEditor -q -str $panel`;

if($query)

modelEditor -e -str 0 $panel;

else

modelEditor -e -str 1 $panel;

break;

case "cv":

$query=`modelEditor -q -cv $panel`;

if($query)

modelEditor -e -cv 0 $panel;

else

modelEditor -e -cv 1 $panel;

break;

case "hull":

$query=`modelEditor -q -hu $panel`;

if($query)

modelEditor -e -hu 0 $panel;

else

modelEditor -e -hu 1 $panel;

break;

case "grid":

$query=`modelEditor -q -gr $panel`;

if($query)

modelEditor -e -gr 0 $panel;

else

modelEditor -e -gr 1 $panel;

break;

case "all":

modelEditor -e -alo 1 $panel;

break;

case "none":

modelEditor -e -alo 0 $panel;

break;

}

}

}



}

Segmoria
05-25-2006, 02:54 PM
When "none" is clicked there should not be any "tick" mark but it is showing tick mark.
This is not the only problem your UI has. When a menuItem is unchecked and you then press "Show>All", it also doesn't check all the menuItems as it should. This happens because you have to manually assign a command, that will describe the action that is to be taken when a menuItem is pressed and you are not defining any commands in your menuItems.

You can do this by creating a seperate proc that will accept a string describing which menuItem has been pressed so that it will refresh the according menuItems. And to do this, you have to give an ID to all your menuItems so you can then query or change their values.
Here it is, have a look at the menuItem creation for the IDs and the procedure that I added at the bottom.

if (`window -ex MA_modelingToolsWin`) deleteUI MA_modelingToolsWin;



window -wh 300 600 -menuBar true -title "MODELING_TOOLS" MA_modelingToolsWin;



//------menu bar-----//



menuBarLayout mainmenu;



//-------Show Menu--------------



menu -l "Show" -to 1 -p "mainmenu" showmenu;

menuItem -l "All" -c("show(\"all\");") menuItem_all;

menuItem -l "None" -c("show(\"none\");") menuItem_none;

menuItem -divider true;

menuItem -checkBox 1 -l "Nurbs Curves" -c("show(\"curves\");") menuItem_nurbsCurves;

menuItem -checkBox 1 -l "Nurbs Surfaces" -c("show(\"surfaces\");") menuItem_nurbsSurfaces;

menuItem -checkBox 1 -l "Polygons" -c("show(\"polygons\");") menuItem_polygons;

menuItem -checkBox 1 -l "Subdiv Surfaces" -c("show(\"subdiv\");") menuItem_subdivSurfaces;

menuItem -checkBox 1 -l "Planes" -c("show(\"planes\");") menuItem_planes;

menuItem -checkBox 1 -l "Lights" -c("show(\"lights\");") menuItem_lights;

menuItem -divider true;

menuItem -checkBox 1 -l "Cameras" -c("show(\"cameras\");") menuItem_cameras;

menuItem -checkBox 1 -l "Joints" -c("show(\"joints\");") menuItem_joints;

menuItem -checkBox 1 -l "IK Handles" -c("show(\"ikhandles\");") menuItem_ikHandles;

menuItem -checkBox 1 -l "Deformers" -c("show(\"deformers\");") menuItem_deformers;

menuItem -checkBox 1 -l "Dynamics" -c("show(\"dynamics\");") menuItem_dynamics;

menuItem -checkBox 1 -l "Fluids" -c("show(\"fluids\");") menuItem_fluids;

menuItem -divider true;

menuItem -checkBox 1 -l "Hair Systems" -c("show(\"hair\");") menuItem_hairSystems;

menuItem -checkBox 1 -l "Follicles" -c("show(\"follicles\");") menuItem_follicles;

menuItem -checkBox 1 -l "Locators" -c("show(\"locators\");") menuItem_locators;

menuItem -checkBox 1 -l "Dimensions" -c("show(\"dimensions\");") menuItem_dimensions;

menuItem -checkBox 1 -l "Pivots" -c("show(\"pivots\");") menuItem_pivots;

menuItem -checkBox 1 -l "Handles" -c("show(\"handles\");") menuItem_handles;

menuItem -divider true;

menuItem -checkBox 1 -l "Textures" -c("show(\"textures\");") menuItem_textures;

menuItem -checkBox 1 -l "Strokes" -c("show(\"strokes\");") menuItem_strokes;

menuItem -checkBox 1 -l "Nurbs CVs" -c("show(\"cv\");") menuItem_nurbsCvs;

menuItem -checkBox 1 -l "Nurbs Hulls" -c("show(\"hulls\");") menuItem_hulls;

menuItem -checkBox 1 -l "Grid" -c("show(\"grid\");") menuItem_grid;

setParent..;

showWindow MA_modelingToolsWin;











//------show Panel--------//



global proc show(string $name)

{

string $panel;

string $type;

int $query;

$panel=`getPanel -up`;

if(""==$panel)

{

$panel=`getPanel -wf`;

}

if(""!=$panel)

{

$type=`getPanel -to $panel`;

if($type=="modelPanel")

{

switch($name)

{

case "curves":

$query=`modelEditor -q -nc $panel`;

if($query)

modelEditor -e -nc 0 $panel;

else

modelEditor -e -nc 1 $panel;

break;

case "surfaces":

$query=`modelEditor -q -ns $panel`;

if($query)

modelEditor -e -ns 0 $panel;

else

modelEditor -e -ns 1 $panel;

break;

case "polygons":

$query=`modelEditor -q -pm $panel`;

if($query)

modelEditor -e -pm 0 $panel;

else

modelEditor -e -pm 1 $panel;

break;

case "subdiv":

$query=`modelEditor -q -sds $panel`;

if($query)

modelEditor -e -sds 0 $panel;

else

modelEditor -e -sds 1 $panel;

break;

case "planes":

$query=`modelEditor -q -pl $panel`;

if($query)

modelEditor -e -pl 0 $panel;

else

modelEditor -e -pl 1 $panel;

break;

case "lights":

$query=`modelEditor -q -lt $panel`;

if($query)

modelEditor -e -lt 0 $panel;

else

modelEditor -e -lt 1 $panel;

break;

case "cameras":

$query=`modelEditor -q -ca $panel`;

if($query)

modelEditor -e -ca 0 $panel;

else

modelEditor -e -ca 1 $panel;

break;

case "joints":

$query=`modelEditor -q -j $panel`;

if($query)

modelEditor -e -j 0 $panel;

else

modelEditor -e -j 1 $panel;

break;

case "ikhandles":

$query=`modelEditor -q -ikh $panel`;

if($query)

modelEditor -e -ikh 0 $panel;

else

modelEditor -e -ikh 1 $panel;

break;

case "deformers":

$query=`modelEditor -q -df $panel`;

if($query)

modelEditor -e -df 0 $panel;

else

modelEditor -e -df 1 $panel;

break;

case "dynamics":

$query=`modelEditor -q -dy $panel`;

if($query)

modelEditor -e -dy 0 $panel;

else

modelEditor -e -dy 1 $panel;

break;

case "fluids":

$query=`modelEditor -q -fl $panel`;

if($query)

modelEditor -e -fl 0 $panel;

else

modelEditor -e -fl 1 $panel;

break;

case "hair":

$query=`modelEditor -q -hs $panel`;

if($query)

modelEditor -e -hs 0 $panel;

else

modelEditor -e -hs 1 $panel;

break;

case "follicles":

$query=`modelEditor -q -fo $panel`;

if($query)

modelEditor -e -fo 0 $panel;

else

modelEditor -e -fo 1 $panel;

break;

case "locators":

$query=`modelEditor -q -lc $panel`;

if($query)

modelEditor -e -lc 0 $panel;

else

modelEditor -e -lc 1 $panel;

break;

case "dimensions":

$query=`modelEditor -q -dim $panel`;

if($query)

modelEditor -e -dim 0 $panel;

else

modelEditor -e -dim 1 $panel;

break;

case "pivots":

$query=`modelEditor -q -pv $panel`;

if($query)

modelEditor -e -pv 0 $panel;

else

modelEditor -e -pv 1 $panel;

break;

case "handles":

$query=`modelEditor -q -ha $panel`;

if($query)

modelEditor -e -ha 0 $panel;

else

modelEditor -e -ha 1 $panel;

break;

case "textures":

$query=`modelEditor -q -tx $panel`;

if($query)

modelEditor -e -tx 0 $panel;

else

modelEditor -e -tx 1 $panel;

break;

case "strokes":

$query=`modelEditor -q -str $panel`;

if($query)

modelEditor -e -str 0 $panel;

else

modelEditor -e -str 1 $panel;

break;

case "cv":

$query=`modelEditor -q -cv $panel`;

if($query)

modelEditor -e -cv 0 $panel;

else

modelEditor -e -cv 1 $panel;

break;

case "hull":

$query=`modelEditor -q -hu $panel`;

if($query)

modelEditor -e -hu 0 $panel;

else

modelEditor -e -hu 1 $panel;

break;

case "grid":

$query=`modelEditor -q -gr $panel`;

if($query)

modelEditor -e -gr 0 $panel;

else

modelEditor -e -gr 1 $panel;

break;

case "all":

modelEditor -e -alo 1 $panel;
refreshCheckBoxes ("all");



break;

case "none":

modelEditor -e -alo 0 $panel;
refreshCheckBoxes ("none");

break;

}

}

}



}


proc refreshCheckBoxes(string $selection)
{
if ($selection == "all")
{
menuItem -e -checkBox 1 menuItem_nurbsCurves;
menuItem -e -checkBox 1 menuItem_nurbsSurfaces;
menuItem -e -checkBox 1 menuItem_polygons;
menuItem -e -checkBox 1 menuItem_subdivSurfaces;
menuItem -e -checkBox 1 menuItem_planes;
menuItem -e -checkBox 1 menuItem_lights;
menuItem -e -checkBox 1 menuItem_cameras;
menuItem -e -checkBox 1 menuItem_joints;
menuItem -e -checkBox 1 menuItem_ikHandles;
menuItem -e -checkBox 1 menuItem_deformers;
menuItem -e -checkBox 1 menuItem_dynamics;
menuItem -e -checkBox 1 menuItem_fluids;
menuItem -e -checkBox 1 menuItem_hairSystems;
menuItem -e -checkBox 1 menuItem_follicles;
menuItem -e -checkBox 1 menuItem_locators;
menuItem -e -checkBox 1 menuItem_dimensions;
menuItem -e -checkBox 1 menuItem_pivots;
menuItem -e -checkBox 1 menuItem_handles;
menuItem -e -checkBox 1 menuItem_textures;
menuItem -e -checkBox 1 menuItem_strokes;
menuItem -e -checkBox 1 menuItem_nurbsCvs;
menuItem -e -checkBox 1 menuItem_hulls;
menuItem -e -checkBox 1 menuItem_grid;
}

if ($selection == "none")
{
menuItem -e -checkBox 0 menuItem_nurbsCurves;
menuItem -e -checkBox 0 menuItem_nurbsSurfaces;
menuItem -e -checkBox 0 menuItem_polygons;
menuItem -e -checkBox 0 menuItem_subdivSurfaces;
menuItem -e -checkBox 0 menuItem_planes;
menuItem -e -checkBox 0 menuItem_lights;
menuItem -e -checkBox 0 menuItem_cameras;
menuItem -e -checkBox 0 menuItem_joints;
menuItem -e -checkBox 0 menuItem_ikHandles;
menuItem -e -checkBox 0 menuItem_deformers;
menuItem -e -checkBox 0 menuItem_dynamics;
menuItem -e -checkBox 0 menuItem_fluids;
menuItem -e -checkBox 0 menuItem_hairSystems;
menuItem -e -checkBox 0 menuItem_follicles;
menuItem -e -checkBox 0 menuItem_locators;
menuItem -e -checkBox 0 menuItem_dimensions;
menuItem -e -checkBox 0 menuItem_pivots;
menuItem -e -checkBox 0 menuItem_handles;
menuItem -e -checkBox 0 menuItem_textures;
menuItem -e -checkBox 0 menuItem_strokes;
menuItem -e -checkBox 0 menuItem_nurbsCvs;
menuItem -e -checkBox 0 menuItem_hulls;
menuItem -e -checkBox 0 menuItem_grid;
}



}

arunspooja
05-27-2006, 11:42 AM
Its working fine

Thank you

CGTalk Moderation
05-27-2006, 11:42 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.