Presentation is loading. Please wait.

Presentation is loading. Please wait.

WORKSHOP 5 CREATING CUSTOM MENU BUTTONS. Workshop Objective –To learn how to create new menu buttons on the main menu bar –To become familiar with using.

Similar presentations


Presentation on theme: "WORKSHOP 5 CREATING CUSTOM MENU BUTTONS. Workshop Objective –To learn how to create new menu buttons on the main menu bar –To become familiar with using."— Presentation transcript:

1 WORKSHOP 5 CREATING CUSTOM MENU BUTTONS

2

3 Workshop Objective –To learn how to create new menu buttons on the main menu bar –To become familiar with using menu builder Software Version –Adams 2012 Files Required –load_the_sweep_macro.cmd –load_the_sweep_macro_and_button.cmd –hood_start.cmd. –custom_window.cmd –test_menu_button_start.cmd.

4 Suggested Exercise Steps 1.Adding new menu button to main menu bar 2.Saving the changes to a menu 3.Restoring the customized menu 4.More about menu builder 5.Modifying the main menu through command language 6.Reviewing the menu hierarchy 7.Creating your own button 8.Structure of menu bar on customized window 9.Adding a push button to custom window menu 10.Changing the hierarchy of the existing menu 11.Optional tasks

5 Step 1. Adding New Menu Button to Main Menu Bar Getting started –Start Adams/View from the directory mod_05_menus and then select Create a new model. Adding new menu buttons to the main menu bar –You can add your own menus and push buttons onto the main menu. How you do this will depend on the extent of the changes you want to make. Sometimes, if you are making several menu modifications, you're better off creating your own interface window and a separate menu structure on that window. That's how the Arc Toolkit from Workshop 04, Macros and Parameter Syntax, was done. –If you're just making a few minor changes to a menu, the easiest way to do that is with the Menu Editor. In other instances, you may prefer to write the command language in a command file that you can import.

6 Step 1. Adding New Menu Button to Main Menu Bar (Cont.) Modifying the main menu using the Menu Builder –If creating a marker using the ribbon menu doesn't give you all the versatility you want, you can access the Command Navigator and use the Marker Create and Marker Modify dialog boxes instead. Let's make those features more convenient by creating a Marker New and Marker Modify push button on the Build Menu as shown below:

7 Step 1. Adding New Menu Button to Main Menu Bar (Cont.) To modify the main menu: 1.From the Tools menu, point to Menu, and then select Modify. The Menu Builder appears. Move it aside slightly so it will be visible even if it were to go behind the main window. 2.Scroll down to the end of the Menu Builder.

8 Step 1. Adding New Menu Button to Main Menu Bar (Cont.) 3.Place your cursor at the end of the last line of the highlighted text as shown below. Place your cursor here

9 Step 1. Adding New Menu Button to Main Menu Bar (Cont.) 4.Press Enter, and then type in the following text outline: MENU1 &CustomMenus MENU2 Mar&ker NAME=Marker BUTTON3 &New... CMD=int com com="marker create" HELP=Create a marker by using a dialog box BUTTON3 &Modify...::Ctrl+M NAME=modify_button CMD=int dia dis dia=.gui.mar_mod HELP=Modify an existing marker

10 Step 1. Adding New Menu Button to Main Menu Bar (Cont.) Your window should look like the one shown below: Tip: Placing an & in the label identifies that the next character will be used as the mnemonic (for example, enter &New to have the resulting menu command be New.)

11 Step 1. Adding New Menu Button to Main Menu Bar (Cont.) 5.To execute the changes to the menu, from the Menu Builder window, select the Menu Bar menu, and then select Apply. 6.In your Adams/View window, scroll the menu bar to see the new menu “CustomMenus” created at the end. Verify the new menu and test the buttons to see if they work. Notice that the status bar displays the help text that you entered for each push button. Scroll here

12 Step 2. Saving the Changes to a Menu Saving the changes to a menu 1.Display the Menu Builder again. 2.From the Menu Bar menu, select Export Text. 3.Save the file as main_vrefresh.mnu. The menu text outline has been saved to your local directory. 4.In the Menu Builder, from the Menu Bar menu, select Exit.

13 Step 3. Restoring the Customized Menu Restoring the customized menu 1.Open a new database (without saving changes), and create a new model. 2.Select the Build menu and look at the menu buttons. 3.Are your customizations there? ____ Yes ____No 4.To load your customized menu into the database, from the Tools menu, point to Menu, and then select Read local Main Menu. Note: The Read local Main Menu command works only if the file is named main_vrefresh.mnu. Also, the file must be located in the local directory (the directory where you started Adams/View, or the current directory as set by File - Select Directory). If you want to load a menu file that has a different name, from the Tools menu, point to Menu, and then select Read. 5.Check the menu bar again, this time you will see the custom buttons. Tip: Try executing the marker modify with the keyboard accelerator shortcut, Ctrl-M.

14 Step 4. More about Menu Builder Other features of the menu builder –Experiment with the Menu Builder features to get a feel for what they do. Then, complete the quiz below. Quiz: –Draw lines to match items in the left column with choices in the right column 1.Repopulates the text Menu Builder with the state of the current menu. 2.Writes the text outline for the menu to a text file. 3.Imports text from a file into the current position of the cursor. 4.Takes the text outline and applies it, thus modifying the menu structure 5.Exits the Menu Builder 6.Takes a menu existing in the database and loads it into the Menu Builder. Load Apply Reload Import Text Export Text Exit

15 Step 5. Modifying the Main Menu through Command Language Modifying the main menu bar by writing command language –Recall that in ADM704A course, Workshop 6, Performing a Design Study, you used a custom menu button (and macro) to sweep the value of a design variable. You would probably agree that using a button on the menu is often simpler than traversing through the multitude of commands available in the Command Navigator. Here you will learn how to create a menu button by writing the command language directly. This alternate approach is helpful because it gives you an organized way to reconstruct a customized menu structure.

16 Step 5. Modifying the Main Menu through Command Language (Cont.) To modify the main menu bar: 1.Start a new database and import the file load_the_sweep_macro.cmd. Adams/View loads the sweep macro into the database where it will be stored with the name.var_swe. Notice that Adams/View does not have a model in the database, as indicated by the title text in the upper left corner of the view window. Since you will be modifying the interface, it is not necessary to have a model open. 2.What is the command prefix for this macro? __________________ Tip: Look in the User-Entered Command text box in the macro editor. Adams/View can auto generate a dialog box for this macro when you supply it with the command prefix you wrote above.

17 Step 5. Modifying the Main Menu through Command Language (Cont.) 3.Execute the following command from the Command Window and it will auto generate and display the dialog box for the sweep macro. interface command_builder command_prefix = “variable sweep” This is the command you should put behind the button to display the dialog box when you click the button. 4.Now compare the following commands: interface command_builder command_prefix = "variable sweep“ interface dialog_box display dialog_box_name =.gui.var_swe

18 Step 5. Modifying the Main Menu through Command Language (Cont.) 5.We had you type the first command instead of the second one for a reason. See if you can identify the best reason from the choices below: (check one) ____ They are equivalent and you need to learn all the different ways of displaying a dialog box. ____ The first command has fewer parameters and would be easier to type. ____ The dialog box.gui.var_swe doesn't yet exist. You can't ask the code to display a dialog box if it hasn't been created first. ____ They have the same number of characters so the reason for choosing one command over the other is irrelevant. 6.Close the Variable Sweep dialog box.

19 Step 6. Reviewing the Menu Hierarchy Reviewing the menu hierarchy –Here you will create a button named Sweep under the menu CustomMenu. Let's see the hierarchy of that menu so we know where to place the new button. To review menu hierarchy: 1.Use the Database Navigator to see the structure of the menu hierarchy. Open the Database Navigator. At the bottom, to the right of the Filter text box, choose All from the option menu. This will allow interface objects, like menus, to be shown. The interface objects are normally filtered out. Expand the gui library and navigate as shown on the figure on the next page..

20 Step 6. Reviewing the Menu Hierarchy (Cont.) Note: You may have to widen the Database Navigator to see the object type.

21 Step 6. Reviewing the Menu Hierarchy (Cont.) 2.Select Design_Variable_select. 3.Select Apply. 4.In the Information window, Adams/View displays information about that interface object:.gui.main.mbar.build.Design_Variable.Design_Variable_select.

22 Step 6. Reviewing the Menu Hierarchy (Cont.) 5.Review the text in the window and circle the best answer, True or False: TF The object is a menu. TF The parent of the object is a Graphic_Interface_Menu. T F A menu button cannot execute more than one command with a single click. T F The parent of the object has two children. (Hint: use the Parent and Children buttons in the info_window). T FYou will soon create a Graphic_Interface_Push_Button that will be a sibling of Design_Variable_New and Design_Variable_select.

23 Step 7. Creating Your Own Button To create your own Sweep button: 1.Open the file load_the_sweep_macro.cmd in a text editor. 2.Scroll down to the section of comments shown here: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! INSERT THE COMMAND TO READ THE CUSTOM MENU FILE "main_refresh.mnu” ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3.Modify the file so it can create the menu named CustomMenu by entering the following command language in the space provided. interface menubar read & menubar=.gui.main.mmenu_menu.mbar_refresh & file="main_refresh.mnu"

24 Step 7. Creating Your Own Button (Cont.) 4.Scroll down to the section of comments shown here: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! INSERT YOUR COMMANDS FOR CREATING PUSH BUTTON BELOW ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 5.Modify the file so it can create the menu push button by entering the following command language in the space provided. Here, the backslash is used as an escape character allowing the quotation mark characters to be seen as literal characters, instead of as the closing quotation mark of the interface command. 6.Save the file as load_the_sweep_macro_and_button.cmd. Now you're ready to test the command file to see if it loads the macro and creates the menu push button. interface push_button & create push_button_name =.gui.mmenu_menu.mbar_refresh.CustomMenus.Design_Variable_Sweep & label = "Sweep.." help_text = "Sweeps the value of a design variable through its absolute range" & commands = "interface command_builder command_prefix = \"variable sweep\" "

25 Step 7. Creating Your Own Button (Cont.) 7.Import the command file you just created. 8.Import the parameterized version of the hood model, hood_start.cmd. 9.Find the new menu button and select Sweep. 10.The Variable Sweep dialog box opens. 11.Sweep the D1 variable. You have learned the two different ways of creating customized menu buttons. For more practice, if time permits, complete the following section.

26 Step 8. Structure of Menu Bar on Customized Window Understanding the structure of a menu bar on a customized window –In Workshop 04, Macros and Parameter Syntax, you used the Arc Tools custom menu. Let's briefly review how it was created.

27 Step 8. Structure of Menu Bar on Customized Window (Cont.) To examine the structure of a menu bar: 1.Open the file custom_window.cmd. Briefly note the following items listed in sequential order: The tk_tools environment variable is set to the appropriate path to the macro files. A custom library named my_cust is created. Several macros are imported and stored in the.my_cust library. An interface window named arc_toolkit is created in the.my_cust library. A menubar, menus, and push buttons are created. The push buttons issue the macro commands for the macros that were imported. An icon is created on the standard toolbar.

28 Step 9. Adding a Push Button to Custom Window Menu Adding a push button to a custom window menu –You need to add one new button to the Arc Tools menu, renamed Simple Arc. To add a push button: 1.Start a new Adams/View session and import the file custom_window.cmd. 2.The standard toolbar is updated with the new icon “Arc Toolkit” 3.Click Menu Bar to load the Arc Toolkit

29 Step 9. Adding a Push Button to Custom Window Menu (Cont.) 4.Select the Create Arc menu and notice that there are four push buttons listed. You need to add another one named Simple Arc. 5.Use the Menu Editor to add the following button to the top of the Create Arc menu. The procedure is similar to the one you used to modify the main menu in Step 1. Adding New Menu Button to Main Menu Bar. Tip: Use Load and Browse for the menu in the library.my_cust. BUTTON2 S&imple Arc NAME=Simple_Arc CMD=interface window undisplay window_name =.my_cust.arc_toolkit CMD=interface command_builder command_prefix = "geometry create curve arc“ CMD=interface window display window_name =.my_cust.arc_toolkit 6.Test your button. Is the proper dialog box displayed?

30 Step 9. Adding a Push Button to Custom Window Menu (Cont.) 7.Save the menu as arc_toolkit.mnu. Consider the repercussions of using both the menu file and the custom_window.cmd file that built the Arc Toolkit. Perhaps the command file to build the Arc Toolkit could be rewritten so it just imports the.mnu file. Do you think it's possible to write a command like that? 8.See if you can find a command that would do that, and write it here: _____________________________________________________

31 Step 10. Changing the Hierarchy of the Existing Menu Changing the hierarchy of an existing menu –The Menu Builder lets you insert menus and buttons anywhere you like within the hierarchy. Conversely, when you make changes to a menu using command language (instead of the Menu Builder) there is a small downside; your changes will always be added to the bottom of an existing menu. This is because the order of creation dictates the placement on the menu. –Therefore, if you are making small changes in hierarchy using command language, your strategy might be to delete (or modify) a menu and to replace it with another, which will of course appear at the bottom of the given menu. Removing a push button –In this section, you will remove a push button and replace it with a menu and two push buttons. As you recall from the ADM704A Class, Workshop 8, Optimization, optimizations will create verbose output in the Command Window and in the file aview.log. Eventually you may want to clear out the log file so it's not so big.

32 Step 10. Changing the Hierarchy of the Existing Menu (Cont.) –In this section, you will create a new menu entry that will clear the contents of the file aview.log. This will replace the Log File menu button with a new hierarchy: Push button Menu Before After Push button

33 Step 10. Changing the Hierarchy of the Existing Menu (Cont.) To remove a push button: 1.Using a text editor, open the file test_menu_button_start.cmd. 2.Review the commands for: Deleting a push button Creating a separator line Creating a new menu entry Creating two new push buttons 3.Notice how the last push button just imports a command file named testit. This trick is a clever way of changing the commands of a push button without manipulating the menu editor as you are debugging the logic in the underlying code. In this case, the testit command file merely issues a message to the screen that the button is working. 4.Import the file test_menu_button_start.cmd.

34 Step 10. Changing the Hierarchy of the Existing Menu (Cont.) 5.Test the menu structure for the log file by selecting the new menu push buttons. When you clear the log file, you will get the following message: 6.Rename the file testit.cmd to testit_0.cmd. 7.From the Tools menu, select Log File, and then select Clear Log File. 8.Did you get the error shown below? ____ Yes ___ No ERROR: Adams/View could not open Command file 'testit.cmd' for reading. When you attempt to clear the log file, it’s trying to read a command file that's no longer there. 9.Create a new file named testit.cmd and copy it the contents of the file named testit_clear.cmd.

35 Step 10. Changing the Hierarchy of the Existing Menu (Cont.) 10.From the Tools menu, point to Log File, and then select Clear Log File. The button works, and displays the following window: 11.Select one of the buttons. 12.Exit Adams/View. Given this scenario of using a button to import a command file that you are debugging, you would eventually need to put the commands behind the button. You would need to change the button command from file command read... to the true set of commands. You can find the completed button syntax for the above example in the file clr_log_file_menu.cmd in the subdirectory from_kb/clr_log_file_menu.

36 Step 11. Optional Tasks Optional tasks 1.Learn some of the other interface commands by importing the file misc/ other_interface_menu_commands.cmd. 2.Create a menu push button named Preview Parts at the bottom of the View menu. Use any method you want to create the push button, but make it use the commands contained in the file misc/preview_parts.cmd. 3.Using the Read Command File button on the Tools menu as a guide, create a menu button called Run Parameterless Macro on the Tools menu, make sure that the button can be executed with a keyboard accelerator (F12 key). See the Tip on the following page regarding accelerator key syntax.

37 Step 11. Optional Tasks (Cont.) Tip: To learn more about accelerator key syntax review the online help about menus. BUTTON2 Run Parameterless Macro::F12 NAME=run_paramless_macro CMD=! Note: F12 shortcut uses this CMD=var set var=$_self.tmp_mac object=(eval(SELECT_OBJECT(DB_DEFAULT(.System_Defaults, "model").parent, "*", "Macro" ))) CMD=var set var=$_self.tmp_str string=(eval(EXECUTE_VIEW_COMMAND(STR_DELETE( (my_macro.object_value),1,1)))) CMD=var del var=$_self.* 4.Test the button by running a recorded macro as well as the parameterless macro constraint_DOF_wiggler.cmd. For more information on parameterless macros, see Writing a parameterless Macro. 5.Create a menu button that will revolve a model about the screen's y-axis in 100 increments, 3.6 degrees each. Use the file revolve_the_model.cmd in the directory misc/revolve as the source for your commands.

38


Download ppt "WORKSHOP 5 CREATING CUSTOM MENU BUTTONS. Workshop Objective –To learn how to create new menu buttons on the main menu bar –To become familiar with using."

Similar presentations


Ads by Google