// =========================================================================== // 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. // =========================================================================== // // Creation Date: Sept 20, 2011 // // Procedure Name: // preformCreateImagePlane // // Description: // // // Input Arguments: // $option : Whether to set the options to default values. // Return Value: // None // proc setOptionVars (int $forceFactorySettings) { if ($forceFactorySettings || !`optionVar -exists freeImageWidth`) { optionVar -floatValue freeImageWidth 10.0; } if ($forceFactorySettings || !`optionVar -exists freeImageHeight`) { optionVar -floatValue freeImageHeight 10.0; } if ($forceFactorySettings || !`optionVar -exists freeImageMR`) { optionVar -intValue freeImageMR 1; } } global proc createImagePlaneCallback (string $parent, int $doIt) // // Description: // Set the optionVar's from the control values, and then perform // the command // { setParent $parent; optionVar -floatValue freeImageWidth `floatSliderGrp -query -value freeImagePlaneWidth`; optionVar -floatValue freeImageHeight `floatSliderGrp -query -value freeImagePlaneHeight`; optionVar -intValue freeImageMR `checkBoxGrp -query -value1 freeImagePlaneMR`; if ($doIt) { performCreateImagePlane 0; addToRecentCommandQueue "performCreateImagePlane 0" "CreateImagePlane"; } } global proc createImagePlaneSetup (string $parent, int $forceFactorySettings) { setOptionVars($forceFactorySettings); setParent $parent; floatSliderGrp -edit -value `optionVar -query freeImageWidth` freeImagePlaneWidth; floatSliderGrp -edit -value `optionVar -query freeImageHeight` freeImagePlaneHeight; checkBoxGrp -edit -value1 `optionVar -query freeImageMR` freeImagePlaneMR; } // // Procedure Name: // createImagePlaneOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc createImagePlaneOptions() { // Name of the command for this option box. // string $commandName = "createImagePlane"; // 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("plane"); // 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; // RECOMMENDATION: Place the UI in a 'scrollable' layout. A // scrollable layout ensures that if the option box window is ever // resized such that it's entire contents is not visible then the // scroll bars provided by the scrollable layout will allow the user // to access the hidden UI. Two layouts currently supporting // scrollable behaviour are the 'scrollLayout' and the 'tabLayout'. // tabLayout -scr true -tv false; // // or... // // tabLayout -tabsVisible 0 -scrollable 1; string $parent = `columnLayout -adjustableColumn 1`; floatSliderGrp -label (uiRes("m_performCreateImagePlane.kImagePlaneWidth")) -field true -step 0.1 -min 1.0 -max 100.0 freeImagePlaneWidth; floatSliderGrp -label (uiRes("m_performCreateImagePlane.kImagePlaneHeight")) -field true -step 0.1 -min 1.0 -max 100.0 freeImagePlaneHeight; checkBoxGrp -label (uiRes("m_performCreateImagePlane.kMaintainPicAspectRatio")) -numberOfCheckBoxes 1 -label1 "" freeImagePlaneMR; // 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 + " " + 0 + "; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Step 7: Set the option box title. // ================================= // setOptionBoxTitle (uiRes("m_performCreateImagePlane.kImagePlaneOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "CreateFreeImagePlane" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // // Return Value: // None. // proc string assembleCmd() { setOptionVars(false); // Initialize the command's parameters float $width = `optionVar -query freeImageWidth`; float $height = `optionVar -query freeImageHeight`; int $mr = `optionVar -query freeImageMR`; // Set the look through camera string $lookThruCam = `lookThru -q`; string $cmd = "imagePlane -width " + $width + " -height " + $height + " -maintainRatio " + $mr + " -lookThrough " + $lookThruCam; return $cmd; } // // Procedure Name: // performCreateImagePlane // // Description: // Perform the optionBoxExample1 command using the corresponding // option values. This procedure will also show the option box // window if necessary as well as construct the command string // that will invoke the optionBoxExample1 command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string performCreateImagePlane(int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Get the command. // $cmd = `assembleCmd`; // Execute the command with the option settings. // evalEcho($cmd); break; // Show the option box. // case 1: createImagePlaneOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }