Patran二次开发工具PCL系列教程之7_第1页
Patran二次开发工具PCL系列教程之7_第2页
Patran二次开发工具PCL系列教程之7_第3页
Patran二次开发工具PCL系列教程之7_第4页
Patran二次开发工具PCL系列教程之7_第5页
已阅读5页,还剩42页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Lecture

7AdvancedPatranGUIProgramming

:Icons,

FileWidget,

SpreadsheetWidgetPAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1IconsPAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1IconExample

:PAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1Types

of

Icon

Widgets

:l

Button

iconl

Item

iconlLabel

iconlToggle

iconPAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1Creatinganicon(UNIX)lUseabitmaputilityprogramsuppliedbyallWorkstationVendors.Usuallycalledbitmap(Sun,SGI).Syntax:•%bitmap[-options...]filename[WIDTHxHEIGHT]•Example:•%bitmap-size16x16happy_face.icon•(a16pixelby16pixelfilenamedhappy_face.icon)PAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1Creating

an

icon

(UNIX)

(cont.)PAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1Creating

an

icon

(NT)lYoucan

usea

Windows

program

called

Paint(underAccessories)to

create

a

windows

bitmap

file

(

.bmp)white

,

or

color

,

as

long

as

it

is

16

x

16

pixelsl

Theiconcan(standard

NTbe

black

and

icon

size)PAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1ParentwidgetID.Mustbeaframe,aform,oramodalform.callbackNameofPCLfunctioncalledforaneventinthiswidget.Thefunctionmustbeintheclassinwhichthewidgetiscreated.Useeventsforthiswidgetarenotofinterest.xXlocationoftoggleininchesrelativetotheparent.yYlocationoftoggleininchesrelativetotheparent.iconNameoftheicontodisplaydescribingthetoggle.u

i_toggleicon_create(

parent,

callback,

x,

y,

icon

)Function:Creates

a

toggleicon

widget.Input:widgetparentstringnumericnumericstringOutput:Toggle

Icon<ReturnValue>widgetToggleiconwidgetID.NULLiftoggleiconwidgetisnotcreated.PAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1logicaltoggleableValueusedonlyformenuitems;ignorediftheitemisnotamenuitem.IfTRUE,theitemwilldisplayatoggleboxnexttotheitem.IfFALSE,theitemwillhaveonlyonevalue.Output:<ReturnValue>widgetItemwidgetID.NULLifitemnotcreated.Comments:Menus,menubars,andswitchesuseitemiconwidgets.Thefunctionalattributesoftheitemaredefinedbytheparentwidgettype.Thepositionoftheitemrelativetoothercurrentlyexistingchildrenfortheparentwidgetisspecifiedbytheorderinwhichtheitemsarecreated,i.e.,theIDoftheparentwidget.Mustbeamenu,menubar,oraswitch.Nameofthewidget.Thisnameisfrequentlyusedasanargumentforthefunctionfortheitem"sparent.Nameofthefilecontainingthehexinformationthatisusedtodescribetheui_itemicon_create(

parent,

name,

iconname,

toggleable

)Function:Creates

aniconitem

widgetto

be

used

as

achild

of

a

menu,

orswitch

widget.Input:widgetparentstringname

callbackstring

iconname

icon.Item

Iconparent

widget,

the

last

item

created

will

appear

last.created

first

will

appear

first

in

thePAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporationitem7-

1(UNIXexample)HowmanyPCLwidgetsdoyou

seehere?File

WidgetPAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1ui

file

createu

i_file_create(

parent,

callback,

x,

y,

width,

num_rows,

filter_label,

filter_mask,

dir

s_label,

files_label,

s

selection,

ok_label,

filter_label,

cancel_label

)Function:Creates

a

file

selection

widget.files_labelLabeltoappearabovethelistboxcontainingthefilesrelevanttothefilter_mask.selection_labelLabeldescribingtheselectiondatabox.selectionFilenametoappearinthedataboxlabeledselection_label.Alsohighlightsinlistbox,ifpresent.ok_labelLabeldescribingtheOKbutton.filter_labelLabeldescribingtheFilterbutton.cancel_labelLabeldescribingtheCancelbutton.Parentwidgetid.Mustbeaframe,aformoramodalform.callbackNameofthePCLfunctionthatiscalledforaneventinthiswidget.hefunctionmustbeintheclassinwhichthewidgetiscreated.Use"ifeventsforthiswidgetarenotofinterest.Xlocationofthewidgetininchesrelativetotheparent.Ylocationofthewidgetininchesrelativetotheparent.Widthofthefilewidget,ininches.Input:widget

parent

stringnumericxnumericynumericwidthinteger

num_rowsstringstringstringstringstringstringstringstringstringWidgetid.NULLifthewidgetcouldnotbecreated.7-1Number

of

items

to

display

in

the

files

and

directory

listboxes.filter_label

Label

describing

the

filter

databox.filter_maskUsedto

specify

which

files

appearin

the

listbox.dir

s_labelLabel

to

appear

above

the

listbox

containing

the

directories.Output:<Return

Value>widgetPAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporationlComments:lThePCLcallbackfunctionwillbecalledwhentheOKbuttonortheCancelbuttonisselected.SelectingtheOKbuttoninstructstheUIMStopasstwoarguments;thecompletepathnameoftheselectedfileand"OPEN."SelectingtheCancelbuttoninstructstheUIMStopasstwoarguments;thefirstisnotusedandwillbesetto"",and"CANCEL."ui

file

create

(cont.)PAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1File

Example

:/***************************************************************

*

Initialize

the

Rebuild

model

form

****************************************************************/FUNCTION

in

it()REAL

x_loc,

y_loc,

wid,

form_hgt,

form_wid,

file_hgtform_wid=

1.6*FORM_WID_SPLwid

=form_widfile_hgt

=

FILE_7L_HGTform_hgt=FORM_2H_MARGIN+FRAME_2EDGE+

file_hgtx_loc=WINDOW_CEN

X

LOC-

0.5*

(

wid

+

FORM_2H_BORDER

)/**

Create

the

"Rebuild

Database"

form*/rebuild_form

=

ui_form_create(@/*

callback

*/

"",

@/*

x

*/

x_loc,

@/*

y*/FORM

Y

LOC,@/*

position

*/

"UL",

@/*

width

*/

wid,

@/*height

*/form_hgt,

@/*label

*/"Rebuild

Database",@/*iconname

*/

""

)PAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1frame

=

ui_frame_create(/*/*

callback

/*

x/*

y/*

width/*

height/*

labelfile

=

ui_file_create(/*

/*

/*

x/*/*/*

num_rows/*

filter_label

*//*

filter_mask

/*

dir

s_labelFile

Example(cont.)/**

Create

the

file

widget*/wid=

formwid

-

FORM

2H

MARGIN

-

FRAME

2EDGE@parent

*/

rebuild_form,@*/

"",

@*/

FORM

L

MARGIN,@*/

FORM

T

MARGIN,@*/

wid,@*/

file_hgt,@*/

""

)@parentcallback*/ywidth*/*/*/0.0,*/*/7,frame,@"rebuild_widget_event",@@0.0,@wid,@@/*

files_label

*/

"Journal

File

List",@/*

selection_label

*/

"Rebuild

From

Journal

File",

@*/

"*.jou",@*/

"Directories",

@PAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation"Filter",

@7-

1_

_

_

_File

Example(cont.)"",

@*/

"Apply",@"Filter",

@"Cancel"

)selection

*//*

ok_label

/*

filter_label

*/

/*

cancel_label

*/END

FUNCTION

/*Init

*/PAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation/*7-

1Spreadsheet

WidgetHowmanyPCLwidgetsdoyou

seehere?PAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1u

i_spread_create(

parent,

callback,

x,

y,

width,

height,label_width,

num_vis_cols,

num_cols,

num_rows,

num_layers,

col_labels,

row_labels,

label,

layer_label,

layer_value_label,

selection_type

)Function:Creates

aspreadsheet

widget.Xlocationofspreadsheetininchesrelativetotheparent.Ylocationofspreadsheetininchesrelativetotheparent.Widthofthespreadsheetininches.Heightofthespreadsheetininches.Widthoftherowlabelsininches.num_vis_colsNumberofvisiblecolumns.num_colsTotalnumberofcolumns.num_rowsTotalnumberofrows.Total

number

of

layers.col_labels

2D

array

of

column

labels,(columns,layers)

.row_labels

2D

array

of

row

labels,(rows,layers)

.Spreadsheetlabel.Layer

databox

label

(for

3D)

.numericxnumericynumericwidthnumericheightnumericlabel_widthintegerintegerIntegerintegerStringStringstringstringstringstringInput:widgetparentParentwidgetIDofnewlycreatedwidget.Mustbeaframe,aform,oramodalform.stringcallbackNameofPCLfunctioncalledforaneventinthiswidget.Thefunctionmusbeintheclassinwhichthewidgetiscreated.Use""ifeventforthiswidgetarenotofinterest.ui

spread

createlayer_value_labelLayervaluedataboxlabel(for3D).selection_type"SINGLE","ROWSELECT","EXTEND","READONLY".Seecommentsbelow.num_layersarrayarraylabellayer_labelPAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1uispreadcreate(cont.)Output:<ReturnValue>widgetWidgetIDofspreadsheetwidget.NULLifnotcreated.Comments:Single-Maypickonlyonecell.Draggingthemouseandpickinglabelshasnoeffect.Rowselect-Pickingacellorlabelselectstheentirerow.Draggingthemousehasnoeffect.Usedforthecoupledlistbox.Extend-Pickmultiplecellsby:1)pickinganddragging.2)pickingstartingcellandthenpickingagainonendingcellwithShiftkeyon.3)pickingcolumnorrowlabelstoselectentirecolumnorrow,respectively.Readonly-Cellsarenotpickable.Scrollbarsarestillactive.Nocallbackiscalled.ThePCLcallbackwillbecalledwhentheuserclicksonthecelldisplayportionofthespreadsheetunlesstheselection_typehasbeensetto"READONLY".Adataboxmustaccompanythiswidgetifdataentry,editing,andexpansionofcellcontentsisneeded.Theapplicationtransfersdataintoandoutofthespreadsheetusingui_spread_set_cellandui_spread_get_cellandthecallbackinformation.Clickingonaroworcolumnlabelselectstheentireroworcolumn.PAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1integerlayerLayertoaccess.stringvalueValuetobeset.Comments:Onecellissetatatime.Ifsettingcelltotheemptystring,useui_spread_cell_deleteinstead.required)u

i_spread_set_cell(

widget_id,

col,

row,

layer,

value

)Function:Sets

a

spreadsheet

cell.Input:widget

widget_idMustbe

aspreadsheet.ui

spread

set

cellintegercolColumnto

access.integerrowRow

to

access.PAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1u

i_spread_

get_cell(

widget_id,

col,

row,

layer,

value

)Function:Get

a

spreadsheet

cell.Input:widget

widget_idintegerintegerintegerOutput:string

valueComments:ui

spread

get

cellMust

be

aspreadsheet.col

Column

to

retrieve.rowRow

to

retrieve.layerLayer

to

retrieve.One

cell

accessed

at

a

time.PAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporationValue

in

cell.7-

1Spreadsheet

Example

:PAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1SpreadsheetExample:/**Purpose:*CreatesthetheClevisCaseSpreadsheetforinputingdesigncases.*ThisPCLClasswascreatedspecificallyforthePAT304trainingclass,*"IntroductiontoPCL"andisintendedtoillustratetheuseofthe*spreadsheetwidget.Thisprogramisnottobeusedforanything*otherthantraining.**Theformisa"Spreadsheet"widget.Ithasthreecolumnsthatdisplay*thecleviswidth,radius,andlengthforeachdesigncase(iteration).*Thewidthandlengtharesetexternally,onlytheradiuscanbe*modifiedinthisform.Thereisamemberfunctionthathandles*theinputofdatatothewidthandlength,fill_data.**//*!!DEBUGON*/#define_NUM_CASES10#include"appforms.p"CLASSspread_sheetCLASSWIDEWIDGETrange_form,spread,input_dboxCLASSWIDESTRINGspread_save[40](_NUM_CASES)CLASSWIDEINTEGERimin_lbl(_NUM_CASES),imax_lbl(_NUM_CASES)CLASSWIDEINTEGERioffset(_NUM_CASES)/*--------------------------------------------------------------------------*/FUNCTION

in

itREAL

x_loc,

y_loc,

label_wid,

wid,

hgtSTRINGcol_labels[20](3,

1)STRING

row_labels[30](35,

1)INTEGER

iPAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1col_labels(

1,

1

)

=

"width

"col_labels(

2,

1

)

=

"

length

"col_labels(

3,

1

)

=

"radius

"FOR(

i=1TO

_NUM_CASES

)row_labels(

i,

1

)

=

"Case

"//str_from_integer

(i)

END

FORwid=FORM_WID_MED*

1.02hgt=SPREADSHEET_HGT_2D_

10ROW*1.02/**

Initialize

:*

----------*/FOR(

i=

1

to_NUM_CASES

)i

offset(i)

=

0spread_save(i)

=

""END

FORSpreadsheet

Example

(cont.)WIDGET

dummy_label_id"",

@FORM

X

LOC_MED_CEN,@FORM

Y

LOC,

@"UL

",

@wid,

@FORM_HGT_TALL,@"ClevisDesign

Cases

",@range_form

=

ui_form_create(/*

/*

/*

/*

/*

/*

/*/**

Create

the

"Clevis

Design

Cases

"

form

:*------------------------------------------------*/@callback

xypositionwidth

height

labelPAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation*/

*/

*/*/

*/

*/*/7-

1/**

Find

the

longest

Entity

label

:*-----------------------------*/dummy_label_id

=

ui_label_create(

range_form,

"",

0.0,

0.0,

"Dummy

"

)

ui_wid_set(

dummy_label_id,

"DISPLAY

",

FALSE

)label_wid

=

0.0FOR(

i=

1

to_NUM_CASES

)ui_wid_set(

dummy_label_id,

"LABEL

",

row_labels(i,

1)

)ui_wid_get(

dummy_label_id,

"WIDTH

",

wid

)IF(

wid

>label_wid

)

THENlabel_wid

=

widEND

FORlabel_wid

+=

20.0*PIXEL_WIDSpreadsheet

Example

(cont.)/*

iconname

*/

""

)input_dbox

=

ui_databox_create(

@/*

parent

*/range_form,

@/*

callback*/

"

input_data

",

@/*

x

*/

x_loc,

@/*

y

*/

y_loc,

@/*

label_length

*/

0.0,

@/*

box_length

*/

DBOX_WID_SINGLE,

@/*label

*/

"

Input

New

Value

",

@/*

value*/

0.0,

@/*label_above*/

TRUE,

@/*

datatype

*/

"REAL

",

@/*

num_vals

*/

1

)/**

Create

the

Neutral

Entities

list

of

items

:*-----------------------------------------*/x_loc=UNFRAMED

L

MARGINy_loc=FORM

T

MARGINPAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1Spreadsheet

Example

(cont.)y_loc+=DBOX_HGT_LABOVE

+

INTER_WIDGET_SPACEspread

=

ui_spread_create(

@/*

parent

*/

range_form,

@/*

callback*/

"

spread_cb

",@/*

x

*/

x_loc,

@/*

y

*/

y_loc,

@/*

width*/

SPREADSHEET_WID_DOUBLE,

@/*

height

*/hgt,

@/*

label_wid

*/

label_wid,

@/*num

v

cols

*/

3,

@/*

num_cols*/

3,

@/*

num_rows*/_NUM_CASES,@/*num_layers

*/

1,

@/*

col_label

*/col_labels,

@/*

row_labels*/

row_labels,

@/*

label

*/

"Clevis

Design

Cases

",

@/*

layer

lab

*/

"",

@/*

layer

v

la*/"",

@/*

selection

*/

"EXTEND

")y_loc+=hgt+SPREADSHEET_2EDGE*

1.02+

INTER_WIDGET_SPACE/**

Create

the

control

buttons

:*--------------------------*/ui_button_create

(

@/*

parent

*/range_form,

@/*callback*/"reset

",

@/*x*/(FORM_WID_MED-BUTTON_WID_THIRD)/2

.,@/*

y

*/

y_loc,

@/*

width

*/

BUTTON_WID_THIRD,

@/*

height

*/

0.0,

@/*

label

*/"Reset

",

@/*

labelinside

*/TRUE,

@/*highlight*/FALSE

)PAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1/**

Create

a

separator

widget.*

-------------------------*/ui_separator_create(

range_form,

"",

0.0,

@y_loc,

@1.02*FORM_WID_MED,TRUE)y_loc+=LINE_THICKNESS+

INTER_WIDGET_SPACEui_button_create(

@/*

parent

*/range_form,

@/*

callback*/

"

done

",

@/*

x

*/

BUTTON_THIRD

X

LOC2,@/*

y

*/

y_loc,

@/*

width

*/

BUTTON_WID_THIRD,

@/*

height

*/

0.0,

@/*label

*/"OK

",

@/*

labelinside

*/TRUE,

@/*highlight*/FALSE

)SpreadsheetExample(cont.)y_loc+=BUTTON_HGT

+

INTER_WIDGET_SPACEui_button_create(/*

parent

*/range_form,/*

callback

*/

"

cancel

",/*x*/

BUTTON_THIRD

X

LOC2_COL2,/*

y

*/

y_loc,/*

width

*/

BUTTON_WID_THIRD,/*

height*/

0.0,/*

label

*/"Cancel

",/*

labelinside

*/TRUE,/*highlight*/FALSE

)y_loc+=BUTTON_HGT

+FORM

B

MARGIN@@@@@@

@@@PAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1Spreadsheet

Example

(cont.)/*--------------------------------------------------------------------------*/FUNCTION

spread_cb(

status,

from_c,

from_r,

to_c,

to_r,

layer

)STRING

status[]INTEGER

from_c,

from_r,

to_c,

to_r,

layerSTRING

cell_data[40]IF(

(from_c==to_c)&&(from_r==to_r))THENui_spread_get_cell(

spread,

from_c,

from_r,

1,

cell_data

)ui_wid_set(input_dbox,"VALUE

",

cell_data

)ELSEui_wid_set(input_dbox,"VALUE

",""

)END

IFEND

FUNCTION

/*spread_cb*//*--------------------------------------------------------------------------*/FUNCTION

input_data

(value)STRING

value[]INTEGER

i,jREAL

dataSTRING

cell_data[40]c

)ol_y,"HTG/nCse_fui_w*EItHim,ONngIaTrFUNet(EiPAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1ui_wid_get(

input_dbox,

"VALUE

",

data

)cell_data

=

str_from_real(data)FOR

(i

=

from_col

to

to_col

)FOR

(

j

=

from_row

to

to_row

)ui_spread_set_cell(

spread,

i,

j,

layer,

cell_data

)END

FOREND

FOREND

IFEND

FUNCTION

/*input

data

*//*--------------------------------------------------------------------------*/FUNCTIONdisplay/**

Display

the

form

after

filling

it

:*/ui_form_display

(

"

spread_sheet

”)Spreadsheet

Example

(cont.)INTEGERfrom_col,from_row,to_col,to_row,layer/**

Retrieve

the

starting

and

ending

column

and

row

positions

and

layer*

for

the

currently

selected(highlighted)

cells

of

the

spreadsheet

:

*/ui_spread_get_selected(

spread,

from_col,

from_row,

to_col,to_row,

layer

)IF

(value

=="CR

")THENPAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1@Spreadsheet

Example

(cont.)/**

Give

the

databox

the

focus

for

immediate

typing:*/ui_set_focus(

input_dbox

)END

FUNCTION/*display*//*--------------------------------------------------------------------------*/FUNCTION

fill_data(min_lbl,

max_lbl

)STRINGmin_lbl[](),

max_lbl[]()INTEGER

jFOR

(

j=

1

to_NUM_CASES

)ui_spread_set_cell(

spread,

1,

j,

1,

min_lbl(j)

)ui_spread_set_cell(

spread,

2,

j,

1,

max_lbl(j)

)END

FOREND

FUNCTION

/*

fill_data

*//*--------------------------------------------------------------------------*/FUNCTION

doneINTEGER

j,

statusSTRING

data[40],an

aly_job_name[5]

(_NUM_CASES)GLOBAL

REAL

radius,

width,lengthGLOBALSTRING

P3_HOMEPAT304CourseNotes–Release

9.5Copyright

2001

MSC.SoftwareCorporation7-

1imin_lbl(j)=STR_TO_INTEGER(data)width=str_to_real(data)/**Getcolumn2data:*/ui_spread_get_cell(spread,2,j,1,data)imax_lbl(j)=STR_TO_INTEGER(data)length=str_t

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论