// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // Procedure Name: // MASHcreateOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // global proc MASHcreateOptions() { // Name of the command for this option box. // string $commandName = "MASHoptions"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // STEP 1: Get the option box. // ============================ // // The value returned is the name of the layout to be used as // the parent for the option box UI. // string $layout = getOptionBox(); setParent $layout; // STEP 2: Pass the command name to the option box. // ================================================= // // Any default option box behaviour based on the command name is set // up with this call. For example, updating the 'Help' menu item with // the name of the command. // setOptionBoxCommandName($commandName); // STEP 3: Activate the default UI template. // ========================================== // // Activate the default UI template so that the layout of this // option box is consistent with the layout of the rest of the // application. // setUITemplate -pushTemplate DefaultTemplate; // STEP 4: Create option box contents. // =================================== // // This, of course, will vary from option box to option box. // Turn on the wait cursor. // waitCursor -state 1; tabLayout -tabsVisible 0 -scrollable 1 -innerMarginWidth 4; string $parent = `columnLayout -adjustableColumn 1 -rowSpacing 4`; columnLayout -adjustableColumn 1 -columnAlign "center" -columnAttach "both" 5 -columnWidth 400; checkBoxGrp -numberOfCheckBoxes 1 -label (getPluginResource("MASH", "kInViewMessages")) mashInViewMessagesCheckbox; checkBoxGrp -numberOfCheckBoxes 1 -label (getPluginResource("MASH", "kHideSourceObjs")) mashHideOriginalObjectCheckbox; setParent..; columnLayout -adjustableColumn 1 -columnAlign "center" -columnAttach "both" 5 -columnWidth 400; radioButtonGrp -numberOfRadioButtons 2 -label (getPluginResource("MASH", "kGeometryType")) -labelArray2 (getPluginResource("MASH", "kMesh")) (getPluginResource("MASH", "kInstancer")) mashGeometryTypeRadio; setParent..; rowLayout -nc 3 -columnWidth3 175 250 30; text -label (getPluginResource("MASH", "kPresetsLocation")) filenameName; textField -fileName "" mashPresetFolderField; string $folderCommand = "AEMASHpresetFileBrowser"; symbolButton -image "navButtonBrowse.png" -c $folderCommand mashBrowseFolders; setParent ..; rowLayout -nc 2 -columnWidth2 175 250 ; text -label (getPluginResource("MASH", "kNetworkName")) defaultNetworkNameLabel; textField -ed true defaultNetworkNameField; setParent ..; columnLayout -adjustableColumn 1 -columnAlign "center" -columnAttach "both" 5 -columnWidth 400; checkBoxGrp -numberOfCheckBoxes 1 -label (getPluginResource("MASH", "kNameOnCreate")) mashNameOnCreationCheckbox; setParent..; rowLayout -numberOfColumns 6 -columnWidth6 175 35 35 35 35 35; text -label (getPluginResource("MASH", "kDistributionType")) defaultNetworkNameLabel; iconTextRadioCollection networkDistributionTypeColl; iconTextRadioButton -st "iconOnly" -i1 "MASH_OptLinear.png" -ann (getPluginResource("MASH", "kLinear")) linearNetwork; iconTextRadioButton -st "iconOnly" -i1 "MASH_OptRadial.png" -ann (getPluginResource("MASH", "kRadial")) radialNetwork; iconTextRadioButton -st "iconOnly" -i1 "MASH_OptGrid.png" -ann (getPluginResource("MASH", "kGrid")) gridNetwork; iconTextRadioButton -st "iconOnly" -i1 "MASH_OptInitialState.png" -ann (getPluginResource("MASH", "kDistInitialState")) initialNetwork; iconTextRadioButton -st "iconOnly" -i1 "MASH_OptZero.png" -ann (getPluginResource("MASH", "kZeroedDist")) zeroNetwork; setParent..; // Turn off the wait cursor. // waitCursor -state 0; // Step 5: Deactivate the default UI template. // =========================================== // setUITemplate -popTemplate; // Step 6: Customize the buttons. // ============================== // // Provide more descriptive labels for the buttons. This is not // necessary, but in some cases, for example, a button labelled // 'Create' may be more meaningful to the user than one labelled // 'Apply'. // // Disable those buttons that are not applicable to the option box. // // Attach actions to those buttons that are applicable to the option // box. Note that the 'Close' button has a default action attached // to it that will hide the window. If a a custom action is // attached to the 'Close' button then be sure to call the 'hide the // option box' procedure within the custom action so that the option // box is hidden properly. // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -command ($callback + " " + $parent + " " + 1) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 1 + "; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Step 7: Set the option box title. // ================================= // string $optionBoxTitle = (getPluginResource("MASH", "kMashOptions")); setOptionBoxTitle($optionBoxTitle); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "MASHOptions" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // MASHoptionsSetup // // Description: // Update the state of the option box UI to reflect the option values. // // Input Arguments: // parent - Top level parent layout of the option box UI. // Required so that UI object names can be // successfully resolved. // // forceFactorySettings - Whether the option values should be set to // default values. // // Return Value: // None. // global proc MASHoptionsSetup(string $parent, int $forceFactorySettings) { setParent $parent; MASHsetOptionVars($forceFactorySettings); int $hideOnCreateOpVar = `optionVar -query mHOC`; int $inViewOpVar = `optionVar -query mIVM`; int $geomTypeOpVar = `optionVar -query mOGTN`; string $presetsFolderOpVar = `optionVar -query mPFL`; string $defaultNameOpVar = `optionVar -query mDNN`; int $nameOnCreationOpVar = `optionVar -query mNOC`; string $distTypeOpVar = `optionVar -query mNDT`; checkBoxGrp -edit -value1 $inViewOpVar mashInViewMessagesCheckbox; checkBoxGrp -edit -value1 $hideOnCreateOpVar mashHideOriginalObjectCheckbox; radioButtonGrp -edit -select $geomTypeOpVar mashGeometryTypeRadio; textField -edit -fileName $presetsFolderOpVar mashPresetFolderField; textField -edit -tx $defaultNameOpVar defaultNetworkNameField; checkBoxGrp -edit -value1 $nameOnCreationOpVar mashNameOnCreationCheckbox; iconTextRadioCollection -edit -sl $distTypeOpVar networkDistributionTypeColl; } // // Procedure Name: // MASHsetOptionVars // // Description: // Initialize the option values. // // Input Arguments: // Whether to set the options to default values. // // Return Value: // None. // global proc MASHsetOptionVars(int $forceFactorySettings) { //in view messages if ($forceFactorySettings || !`optionVar -exists mIVM`) { optionVar -iv mIVM 1; } //hide on create if ($forceFactorySettings || !`optionVar -exists mHOC`) { optionVar -iv mHOC 1; } //out geomtery type if ($forceFactorySettings || !`optionVar -exists mOGTN`) { optionVar -iv mOGTN 1; //default is Repro mesh } //preset folder location - blank because we don't have write access to the MASH presets folder. if ($forceFactorySettings || !`optionVar -exists mPFL`) { string $presetsFolderLocation = ""; } //preset folder location if ($forceFactorySettings || !`optionVar -exists mDNN`) { string $defaultNetworkName = "MASH#"; optionVar -sv mDNN $defaultNetworkName; } //name on creation if ($forceFactorySettings || !`optionVar -exists mNOC`) { optionVar -iv mNOC 0; } //default distribution if ($forceFactorySettings || !`optionVar -exists mNDT`) { optionVar -sv mNDT "linearNetwork"; } } // // Procedure Name: // MASHoptionsCallback // // Description: // Update the option values with the current state of the option box UI. // // Input Arguments: // parent - Top level parent layout of the option box UI. Required so // that UI object names can be successfully resolved. // // doIt - Whether the command should execute. // // Return Value: // None. // global proc MASHoptionsCallback(string $parent, int $doIt) { int $inViewOpVar = `checkBoxGrp -query -value1 mashInViewMessagesCheckbox`; int $hideOnCreateOpVar = `checkBoxGrp -query -value1 mashHideOriginalObjectCheckbox`; int $geomTypeOpVar = `radioButtonGrp -query -select mashGeometryTypeRadio`; string $filePathOpVar = `textField -query -fileName mashPresetFolderField`; string $defaultNameOpVar = `textField -query -tx defaultNetworkNameField`; int $nameOnCreationOpVar = `checkBoxGrp -query -value1 mashNameOnCreationCheckbox`; string $defaultDistributionOpVar = `iconTextRadioCollection -query -sl networkDistributionTypeColl`; optionVar -iv mIVM $inViewOpVar; optionVar -iv mHOC $hideOnCreateOpVar; optionVar -iv mOGTN $geomTypeOpVar; optionVar -sv mPFL $filePathOpVar; optionVar -sv mDNN $defaultNameOpVar; optionVar -iv mNOC $nameOnCreationOpVar; optionVar -sv mNDT $defaultDistributionOpVar; MASHnewNetwork($defaultNameOpVar); } // // Procedure Name: // AEMASHpresetFileBrowser // // Description: // Presents a file browser and returns the filename // // Input Arguments: // None. // // doIt - Whether the command should execute. // // Return Value: // None. // global proc AEMASHpresetFileBrowser() { string $filename[] = `fileDialog2 -fileMode 3 -caption (getPluginResource("MASH", "kSelectFolder"))`; if (1 == `size($filename)`) { textField -edit -fileName $filename[0] mashPresetFolderField; } }