Msc. Patran pcl handbook In a Nutshell 7


Exercise 12: Primitive Graphics



Download 1.08 Mb.
Page18/25
Date05.08.2017
Size1.08 Mb.
#26706
1   ...   14   15   16   17   18   19   20   21   ...   25

Exercise 12: Primitive Graphics


Create a form that uses primitive graphics to either:

  1. Draw a line between two points, or

  2. Label individual nodes.

Be sure to:



    1. Use ui_colormenu_create(…) to allow the user to change the color of the lines or labels

    2. Use a select frame with an Auto Execute toggle

    3. Have a “Reset Graphics” button that calls gm_segment_delete(…) to erase the graphics.

You will use the following primitive graphic functions:

  1. gm_segment_create(…)

  2. Either gm_draw_line(…) or gm_draw_text(…)

  3. gm_segment_flush(…)

  4. gm_segment_delete(…)



MSC.Patran Customization

Adding Utility Programs to the Main Menu


  • Pulldown menus can be added to MSC.Patran’s top menubar.

  • I

    Menubar on MSC.Patran’s main or primary form. Includes File, Group, etc. The widget Id is obtained via uil_primary.get_menubar_id()

    User-defined menu. This menu widget is a child of MSC.Patran’s main menubar widget. This widget is created with the ui_menu_create(…) function

    Menu items are children of the user-defined menu widget. These are added to the user-defined menu with the ui_item_create(…) function. Functions are executed based on item name passed to the menu callback function.
    ndividual items on the pulldown menu can be used to open user-defined forms or other PCL functions.

MSC.Patran Customization

Example




    CLASS my_pulldown_menu

    CLASSWIDE WIDGET user_menu

    FUNCTION init()

    WIDGET menubar

    menubar = uil_primary.get_menubar_id()



    user_menu = ui_menu_create(menubar, “user_menu_cb”, “My_Menu”)



    ui_item_create(user_menu, “hello_world”, “Hello World!”, FALSE)

    ui_item_create(user_menu, “dump_nodes”, “Write Nodal Data”, FALSE)

    ui_item_create(user_menu, “”, “”, FALSE)

    ui_item_create(user_menu, “push_me”, “Push Me …”, FALSE)

    ui_item_create(user_menu, “football”, “Football Scores …”, FALSE)

    ui_item_create(user_menu, “group_by_shape”, “Group Elms By Shape …”, FALSE)

    END FUNCTION /* init */

    FUNCTION display()

    /* Dummy display function. The display function is not really necessary

    since the menubar is automatically displayed by MSC.Patran. */

    END FUNCTION /* display */


    The item “name” parameter is passed as an argument to the callback function (user_menu_cb) of the menu.






    FUNCTION user_menu_cb(item)

    STRING item[]

    SWITCH (item)

    CASE (“hello_world”)

    hello_world()

    CASE (“dump_nodes”)

    DumpNodes(“MyFile.dat”)

    CASE (“push_me”)

    ui_exec_function(“push_me_form”, “display”)

    CASE (“football”)

    ui_exec_function(“football_scores”, “display”)

    CASE (“group_by_shape”)

    ui_exec_function(“group_elms_by_shape”, “display”)

    END SWITCH

    END FUNCTION /* user_menu_cb */

    END CLASS /* my_pulldown_menu */

MSC.Patran Customization

  • If the Shareware, i.e., Utilities is loaded, adding user-defined pulldown menus is even easier!

  • The Utilities pulldown menu is defined in a file called, p3_user_menu.def.

  • In addition to adding the contents of the p3_user_menu.def file to MSC.Patran’s top menubar, the shareware will add additional pulldown menus defined in files named, p3_user_menu.*.def, i.e., p3_user_menu.4me.def.

  • Up to 3 additional pulldown menus can be defined.

  • The shareware looks for p3_user_menu.*.def files in your current directory, home directory, MSC.Patran installation directory, and the shareware directory.

Example: p3_user_menu.my_menu.def



    Menu label




    *MENU LABEL = My_Menu



    *
    Executes a function that is not contained within a PCL Class. The function cannot have any arguments.
    CLASS = -NA-


    *FUNCTION = hello_world

    *LABEL = Hello World!

    *LOAD ITEM

    *SEPARATOR

    *CLASS = push_me_form

    *
    Opens a form via the

    ui_exec_function(classname, function) command.
    Example:

    ui_exec_function(“football_scores”, “display”)
    FUNCTION = display


    *LABEL = Push Me …

    *LOAD ITEM



    *CLASS = football_scores

    *FUNCTION = display

    *LABEL = Football Scores …

    *LOAD ITEM

    *CLASS = group_elms_by_shape

    *FUNCTION = display

    *
    Pulldown menus are designed to open forms. This is why selecting a menu item executes:

    ui_exec_function(…)


    LABEL = Group Elms By Shape …


    *LOAD ITEM

MSC.Patran Customization

C
ustomizing the MSC.Patran Toolbar




  • MSC.Patran’s toolbar is controlled by a file called p3toolbar.def.

  • MSC.Patran looks for this file first in your home directory and then in the MSC.Patran installation directory.

  • T
    PCL function that will be executed is:

    uil_toolbar.rotate_xy()
    he file format is very similar to the format used for the p3_user_menu.def file.



    *ICON = tbrotatexy.28.icon

    *
    Toolbar icons are designed to perform an action. This is why selecting an icon executes the classname.function() instead of

    ui_exec_function(…)


    CLASS = uil_toolbar


    *FUNCTION = rotate_xy

    *HELP = Mouse rotate XY

    *LOAD ITEM



    *ICON = tbploterase.icon

    *CLASS =

    *FUNCTION = tbd(uil_imaging_plot_erase)

    *HELP = Plot/Erase form (Display menu)

    *LOAD ITEM


    Executes the function tbd(classname). The tbd functon in turn executes: ui_exec_function(“classname”, “display”), i.e., the tbd function is used to open a form from the toolbar.


MSC.Patran Customization

  • If you use an icon that is not in the MSC.Patran icons directory then you will need to define the location of the icon file in the p3midilog.pcl file. Typically, the p3midilog.pcl file would be located in your home directory.

  • Toolbar icons can be any size. However, all icons on the default toolbar are 28x28 (pixels) on UNIX and 16x16 on NT.

  • For UNIX (i.e., Motif), the icons are in xbm format. For NT, the icons can be in either xbm format or bmp format (bitmap).

  • On UNIX, the icons must be black and white. On NT, the icons can be color if the bmp format is used.

  • On UNIX workstations, a program like bitmap can be used to create the icons.

  • On a PC, a program like Microsoft Windows Paint can be used to create the icons.




MSC.Patran Customization

  • To add your own toolbar function/icon

  1. Create the PCL function and compile it into a library if it does not exist.

  2. Make sure there are proper entries in your p3epilog.pcl file that tell MSC.Patran where to find the library that contains your function.

  3. Create an icon by editing one of the existing toolbar icons using bitmap or its equivalent.

  4. Add appropriate statements to your p3toolbar.def file.

  5. Add a !!PATH statement to your p3midilog.pcl file telling MSC.Patran where to look for the icon file.





Download 1.08 Mb.

Share with your friends:
1   ...   14   15   16   17   18   19   20   21   ...   25




The database is protected by copyright ©ininet.org 2024
send message

    Main page