Msc. Patran pcl handbook In a Nutshell 7



Download 1.08 Mb.
Page14/25
Date05.08.2017
Size1.08 Mb.
#26706
1   ...   10   11   12   13   14   15   16   17   ...   25

Select Mechanism


PCL offers a set of widgets and functions to enable the selection of entities from the Viewport. These tools are typically referred to collectively as the MSC.Patran Select Mechanism. The Select Mechanism includes the use of Select Frame, Select Databox widgets, and MSC.Patran’s List processor PCL calls.

Select Mechanism GUI Mechanics

Select Databoxes, Select Frames, and Select Menus


  • The Select Databox is used to interact with the model by letting the user select different types of entities, i.e., curves, surfaces, elements, element faces, nodes, etc.

  • The resulting data in the Select Databox is referred to as a Picklist

A Picklist is a character string that appears in the Select Databox as a result of a user selection or user entered data.

  • The Picklist is processed by MSC.Patran’s List Processor

  • A Select Menu is associated with a Select Databox. There is a predefined, finite set of Select Menus available in MSC.Patran. Select Menus are used to filter which entity types are selected.

  • The parent widget of a Select Databox must be a Select Frame.

  • The Select Mechanism can be made to Auto Execute by labeling the Select Frame “Auto Execute” or using the #define AUTO_EXECUTE statement defined by the appstrings.p define file.

“Auto Execute” is the action of automatically running the “Apply” function when the last Select Databox within the Select Frame is filled.

Select Mechanism



  • The Select Menu is displayed when focus is given to a Select Databox.

  • Focus policy can be controlled within PCL by using the ui_set_focus(MyWidget) and the select_focus.exit() functions.

  • The widget callback of a Select Databox is a string indicating the action of GAIN or LOSE.

Other less often-used callback returns include CR and WIDSET

  1. When another Select Databox gains focus the new Select Menu is automatically displayed.

  2. When closing a form, it is necessary to run select_focus.exit() to close the Select Menu. Otherwise the Select Menu form will remain on the screen.




  • T
    FUNCTION cancel_cb()

    select_focus.exit()

    ui_form_hide( CLASSNAME )

    END FUNCTION

    ogether, the Select Databox, Select Frame, and Select Menu are referred to as the select mechanism. The PCL widget functions for a select mechanism are:

ui_selectframe_create(), ui_selectdatabox_create()

Select Mechanism


GUI PCL Example


sframe_id = ui_selectframe_create ( @

/* parent */ form_id, @

/* callback */ "apply_cb", @

/* Left_margin */ FORM_L_MARGIN, @

/* Y Location */ yloc, @

/* col_width */ SFRAME_WID_SINGLE, @

/* height */ SFRAME_1SDB_HGT_LABOVE,@

/* Label */ “Auto Execute”, @

/* recycle */ TRUE )
sdbox_width= SDBOX_WID_SINGLE - 2*SFRAME_R_MARGIN
select_data_box1 = ui_selectdatabox_create ( @

/* parent_frame */ sframe_id, @

/* callback */ "", @

/* Left_margin */ SFRAME_L_MARGIN, @

/* Y Location */ SDBOX_Y_LOC1_LABOVE, @

/* label_length */ 0.0, @

/* Box_length */ sdbox_width, @

/* label */ "Curve List", @

/* default_value */ "" , @

/* label_above */ TRUE, @

/* data_type */ "CURVE", @

/* prompt */ "select a filter" )


Select Databox






yloc += SFRAME_1SDB_HGT_LABOVE + SFRAME_2EDGE +
INTER_WIDGET_SPACE




Select Mechanism


List Processor

List Processor Mechanics


  • The List Processor evaluates or parses a Picklist for information that the application needs.

  • The Picklist is retrieved from the specified Select Databox using the ui_wid_get_vstring() command. This command automatically sizes a virtual string to store the picklist data.

  • The low level, more flexible List Processor functions begin with the prefix, lp_. In addition to these functions, there are other more "user friendly" functions which perform more specific tasks.

  • The “user friendly” functions also offer another benefit. Most lp_ functions make calls to the database to obtain information about the Picklist. The more user-friendly functions, such as the fem_u_ functions, only evaluate for ids and do not require querying the database. This gives the benefit of improved performance.

  • When using the List Processor functions it is necessary to #include the lpenums.p file with the C Preprocessor (cpp). This file contains all the keywords used to define the evaluation methods for interpreting the Picklist with the various List Processor functions.

Select Mechanism



  • A Picklist may be comprised of one or more sublists. Each sublist in a Picklist has a type and attributes associated to it.

If a user is selecting nodes and elements, each of the entity types would comprise a sublist. The Picklist, “Node 1 2 45 Element 2 4 6” contains two sublists based on use of the lp_sublist_node and lp_sublist_element sublist filters.



All You Really Need to Know


  • Although the low-level lp_ functions offer the most flexibility and are more complete than the fem_u functions, they are also generally more complicated to use.

  • Refer to Appendix H for a more complete description of the lp_ functions

  • The most popular list processor functions are:

  • fem_u_count_id_list(…) – This function counts how many entities (nodes, elements, surfaces, etc.) have been selected.

  • fem_u_get_id_list(…) – This function extracts the entities Ids from the picklist and places them in an integer array.

  • fem_u_get_subid_list(…) – This function extracts subentities, i.e., element edge or face Ids.

Select Mechanism



  • Usage: fem_u_count_id_list(…)

num_ids = fem_u_count_id_list(sublist_type, picklist, @
do_message, status)

INPUT:

sublist_type INTEGER See note below

picklist STRING

do_message LOGICAL

status INTEGER
OUTPUT:

num_ids INTEGER

  • Usage: fem_u_get_id_list(…)

fem_u_get_id_list(sublist_type, picklist, num_ids, @
do_message, ids)

Argument definitions are similar to above

  • The sublist types can be any of the following: LP_SUBLIST_FINITE_ELEMENT, LP_SUBLIST_NODE, LP_SUBLIST_ELEMENT, LP_SUBLIST_MPC, LP_SUBLIST_GEOMETRY, LP_SUBLIST_POINT, LP_SUBLIST_CURVE, LP_SUBLIST_SURFACE, LP_SUBLIST_SOLID, LP_SUBLIST_ANY

  • The sublist types are defined in the lpenums.p file

Select Mechanism

  • Example

FUNCTION apply_cb()

INTEGER status

STRING node_list[VIRTUAL]

ui_wid_get_vstring(node_sdbox, “VALUE”, node_list)

status = do_something_spectacular(node_list)

END FUNCTION /* apply_cb */

FUNCTION do_something_spectacular(node_list)

INTEGER status

INTEGER num_nodes, node_ids(VIRTUAL)

STRING node_list[]

num_nodes = fem_u_count_id_list(LP_SUBLIST_NODE, @

node_list, FALSE, status)

IF (num_nodes == 0) THEN RETURN (-1)

sys_allocate_array(node_ids, 1, num_nodes)

fem_u_get_id_list(LP_SUBLIST_NODE, node_list, @

num_nodes, FALSE, node_ids)

RETURN (0)

END FUNCTION /* do_something_spectacular */



Download 1.08 Mb.

Share with your friends:
1   ...   10   11   12   13   14   15   16   17   ...   25




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

    Main page