// =========================================================================== // 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: August 14, 1996 // // Description: // This script is a script for option box dialog for textCurves command. // // Input Arguments: // int action // 0 - just execute the text curves operation // 1 - show the option box dialog // 2 - drag to shelf // // Return Value: // None. // // pull in scripts that define routines needed for bevelled text source "performBevelPlus"; // most stuff is sitting in here source "bevelPlusToolScript"; // defines bevelPlusToolSetup proc setOptionVars (int $forceFactorySettings) { textCurvesSetOptionVars( $forceFactorySettings ); } // // Procedure Name: // textCurvesSetup // // Description: // Update the state of the option box UI to reflect the textCurves // 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 textCurvesSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Query the optionVar's and set the values into the controls int $localIntValue; string $localStringValue; $localIntValue = `optionVar -q textCurvesType`; if( `isTrue SurfaceUIExists` ) { radioButtonGrp -e -sl ($localIntValue+1) textCreateTypeBtn; } else { if( 1 == $localIntValue ) $localIntValue = 2; radioButtonGrp -e -sl ($localIntValue/2 + 1) textCreateTypeBtn; } if( $localIntValue == 2 ) { tabLayout -e -vis true -st textCurveOptionsOK textCurveOptions; } else if( $localIntValue == 3 ) { tabLayout -e -vis true -st textCurveOptionsBevel textCurveOptions; } else { tabLayout -e -vis false textCurveOptions; } nurbsToPolySetup( $parent, $forceFactorySettings ); bevelPlusBasicSetup( $parent, $forceFactorySettings, "" ); // no tool setup $localStringValue = `optionVar -q textCurvesFont`; string $tokens[]; tokenize $localStringValue "|" $tokens; textFieldGrp -e -text $tokens[0] font; $localStringValue = `optionVar -q textCurvesText`; textFieldGrp -e -text $localStringValue text; } // // Procedure Name: // textCurvesCallback // // 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 textCurvesCallback(string $parent, int $doIt) { setParent $parent; // Set the optionVar's from the control values, and then perform the // command if( `isTrue SurfaceUIExists` ) { optionVar -intValue textCurvesType (`radioButtonGrp -q -sl textCreateTypeBtn` - 1); } else { optionVar -intValue textCurvesType ((`radioButtonGrp -q -sl textCreateTypeBtn` - 1)*2); } optionVar -stringValue textCurvesText (`textFieldGrp -q -text text`); nurbsToPolyCallback( $parent, 0 ); bevelPlusCallback( $parent, 0, "" ); // no tool if ($doIt) { performtextCurves 0; addToRecentCommandQueue "performtextCurves 0" "Text"; } } // // Procedure Name: // textCurvesTabBasic // // Description: // Fill the contents of the option box for textCurves command. // // Input Arguments: // The name of the parent layout. // // Return Value: // None. // global proc textCurvesTabBasic(string $parent) { setParent $parent; string $tabForm = `columnLayout -adjustableColumn true`; formLayout textLayout; textFieldGrp -label (uiRes("m_performtextCurves.kText")) text; setParent ..; formLayout fontTotalLayout; string $fontLayout = `formLayout`; // the font text field will not be editable by the user - the // string will come from the popup menu // textFieldGrp -label (uiRes("m_performtextCurves.kFont")) -ed false font; setParent ..; formLayout fontMenuLayout; symbolButton -image "pickMenuIcon.png" -command ("createFontPopup " + "-scalable " + "resetFontFieldText " + "NULL " + $fontLayout ); setParent ..; setParent ..; // layout the font field and popup button side by side // formLayout -e -ac fontMenuLayout left 0 $fontLayout fontTotalLayout; string $type = (uiRes("m_performtextCurves.kType")); string $curves = (uiRes("m_performtextCurves.kCurves")); string $poly = (uiRes("m_performtextCurves.kPoly")); string $bevel =(uiRes("m_performtextCurves.kBevel")); if( `isTrue SurfaceUIExists` ) { radioButtonGrp -nrb 4 -label $type -label1 $curves -label2 (uiRes("m_performtextCurves.kTrim")) -label3 $poly -label4 $bevel -cc1 "tabLayout -e -vis false textCurveOptions" -cc2 "tabLayout -e -vis false textCurveOptions" -cc3 "tabLayout -e -vis true -st textCurveOptionsOK textCurveOptions" -cc4 "tabLayout -e -vis true -st textCurveOptionsBevel textCurveOptions" textCreateTypeBtn; } else { radioButtonGrp -nrb 3 -label $type -label1 $curves -label2 $poly -label3 $bevel -cc1 "tabLayout -e -vis false textCurveOptions" -cc2 "tabLayout -e -vis true -st textCurveOptionsOK textCurveOptions" -cc3 "tabLayout -e -vis true -st textCurveOptionsBevel textCurveOptions" textCreateTypeBtn; } separator; tabLayout -tabsVisible false textCurveOptions; string $par = `columnLayout textCurveOptionsOK`; nurbsToPolyAddOptions $par; setParent ..; string $par2 = `columnLayout textCurveOptionsBevel`; setParent $par2; createBevelBasicOptions; setParent ..; setParent ..; } // // Procedure Name: // textCurvesHelp // // Description: // Returns a short description about the textCurves command. // // Input Arguments: // None. // // Return Value: // string. // proc string textCurvesHelp() { return " Command: TextCurves - creates curves for the given text.\n" + "Selection: none."; } // // Procedure Name: // textCurvesOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc textCurvesOptions() { string $commandName = "textCurves"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // Step 1: Get the option box. // ============================ string $layout = getOptionBox(); setParent $layout; // Step 2: Pass the command name to the option box. // ================================================= setOptionBoxCommandName($commandName); // Step 3: Activate the default UI template. // ========================================== setUITemplate -pushTemplate DefaultTemplate; // Step 4: Create option box contents. // =================================== // Turn on the wait cursor. // waitCursor -state 1; tabLayout -scr true -tv false; string $parent = `columnLayout -adjustableColumn 1`; textCurvesTabBasic $parent; // Turn off the wait cursor. // waitCursor -state 0; // Step 5: Deactivate the default UI template. // =========================================== // setUITemplate -popTemplate; // Step 6: Customize the buttons. // ============================== // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performtextCurves.kCreate")) -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_performtextCurves.kTextCurvesOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "CreateText" ); // 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 textCurves command that will apply the option box // values. // // Input Arguments: // None. // // Return Value: // The textCurves command string. // proc string assembleCmd() { setOptionVars(false); // get the global history flag value int $doHistory = `constructionHistory -q -tgl`; // the type for the result int $dohow = `optionVar -q textCurvesType`; if( (1 == $dohow) && ! `isTrue SurfaceUIExists` ) { $dohow = 2; } // the font type to use for the text string $dofont = `optionVar -q textCurvesFont`; // text string to make into curves string $text = `optionVar -q textCurvesText`; // replace any \ by \\ and " by \" in the string so that textCurvesSet() // will have these characters and the text command can create the \ and " // as well // string $totalText = substituteAllString( $text, "\\", "\\\\" ); $totalText = substituteAllString( $totalText, "\"", "\\\"" ); string $cmd; if(3 == $dohow) { // set up string for textHistory case $cmd = "textCurvesBevel"; $cmd = $cmd + "(" ; $cmd = $cmd + "\"" + $dofont + "\""; $cmd = $cmd + ","; $cmd = $cmd + "\"" + $totalText + "\""; $cmd = $cmd + ")"; } else { // set up string for non-text-history cases $cmd = "textCurvesSet"; $cmd = $cmd + "(" ; $cmd = $cmd + $doHistory; $cmd = $cmd + ","; $cmd = $cmd + $dohow; $cmd = $cmd + ","; $cmd = $cmd + "\"" + $dofont + "\""; $cmd = $cmd + ","; $cmd = $cmd + "\"" + $totalText + "\""; $cmd = $cmd + ")"; } return $cmd; } // // Procedure Name: // performtextCurves // // Description: // Perform the textCurves 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 textCurves command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command to drag to shelf. // // Return Value: // The textCurves command string. // global proc string performtextCurves( int $action ) { string $cmd = ""; switch($action ) { // Execute the command. // case 0: // Retrieve the option settings // setOptionVars(false); // Get the text command. // $cmd = `assembleCmd`; // Execute the command with the option settings. // eval($cmd); break; // Show the option box. // case 1: textCurvesOptions; break; // Return the command string. // case 2: // Retrieve the option settings. // setOptionVars( false ); // Get the command for dragging to shelf. // $cmd = `assembleCmd`; break; } return $cmd; }