0% found this document useful (0 votes)
96 views14 pages

Aiditemlist PMLFRM

This document contains the definition of methods for an Aid item list form in PML. The form allows the user to view and manage different types of aid elements like lines, circles, and grids. Methods are defined to initialize the form, load/save elements from files, select element types, and delete selected items.

Uploaded by

YoussefOuchrif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views14 pages

Aiditemlist PMLFRM

This document contains the definition of methods for an Aid item list form in PML. The form allows the user to view and manage different types of aid elements like lines, circles, and grids. Methods are defined to initialize the form, load/save elements from files, select element types, and delete selected items.

Uploaded by

YoussefOuchrif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 14

------------------------------------------------------------------------

--
-- Copyright 1974 to current year. AVEVA Solutions Limited and its subsidiaries.
All rights reserved in original code only.
--
-- File: aiditemlist.pmlfrm
-- Type: Form Definition
-- Group: Aid element handlers
-- Keyword: AID
-- Module: common
-- Replaces:
--
-- Author: N.Holmes
-- Created: Fri Feb 13 17:50:43 WAT 1998
--
--
-- Description:
-- Aid constructor control form.
--
------------------------------------------------------------------------
--
-- Methods defined:
--
-- Method call Return Description
-- =========== ====== ===========
-- aidItemList() - Constructor
-- delete(STRING) - Delete selected entries
-- edit() - Show graphic aid
definition form
-- initialise() - Initialisation for form
-- limits() - Set view limits to
selected entries from the list
-- load() - Load graphics from file
-- save() - Save graphics to file
-- select(GADGET,STRING) - Select entry
-- selectAll() - Select all elements in
current list
-- selectType() - Select aid type
-- setupMenus() - Setup menus
-- string() STRING Accessible description of
form
-- tag(BOOLEAN) - Tag passed item
-- tag(MENU,STRING) - Tag selection
-- unSelect() -
-- visible(BOOLEAN) - Remove selected entries
from the list
--
------------------------------------------------------------------------

-- Define form
setup form !!aidItemList
Import 'pmlfilebrowser'
handle any
endhandle

!!aidItemList.formTitle = 'Aid Constructors'


!!aidItemList.iconTitle = 'aids'
!!aidItemList.callback = '!this.initialise()'
!!aidItemList.formRevision = ' $Revision: 1.16 $ '
-- Body of form definition

-- Bar menu
bar
exit

-- Options
option .type 'Aid type ' callback '!!aidItemList.selectType()' width 14

-- Available Items
list .aids at xmin ymax callback '!!aidItemList.select(' multiple width 40
length 10

-- Form Members
member .label is BOOLEAN
member .detail is BOOLEAN

exit
-- End of form definition for !!aidItemList

------------------------------------------------------------------------
--
-- Method: aidItemList
--
-- Description:
-- Constructor
--
-- Method Type: Function/Procedure
-- Arguments:
-- [#] [R/RW] [Data Type] [Description]
-- Return:
-- [Data Type] [Description]
--
------------------------------------------------------------------------

define method .aidItemList()

-- Build Bar menu


!bar = !this.bar
!bar.add('Control', 'controlMenu')
!bar.add('Edit', 'editMenu')
!bar.add('Display', 'displayMenu')
!bar.add('Settings', 'settingsMenu')
!bar.add('Delete', 'deleteMenu')

-- Control menu
!menu = !this.newMenu('controlMenu')
!menu.add('CALLBACK', 'Save as...', '!this.save()')
!menu.add('CALLBACK', 'Load from...', 'call !!fileBrowser(|%AVEVA_DESIGN_USER
%|, ''*.pmldat'', ''Load Construction Graphics'', true, ''!!aidItemList.load()'')')
!menu.add('separator')
!menu.add('CALLBACK', 'Close', '!this.hide()')

-- Edit Menu
!menu = !this.newMenu('editMenu')
!menu.add('CALLBACK', 'Definition...', '!this.edit()')
!menu.add('separator')
!menu.add('CALLBACK', 'Select all', '!this.selectAll()')
!menu.add('CALLBACK', 'Unselect', '!this.unSelect()')

-- Display Menu
!menu = !this.newMenu('displayMenu')
!menu.add('CALLBACK', 'Show', '!this.visible(true)')
!menu.add('CALLBACK', 'Limits', '!this.limits()')
!menu.add('CALLBACK', 'Hide', '!this.visible(false)')
!menu.add('separator')
!menu.add('CALLBACK', 'Tag', '!this.tag(true)')
!menu.add('CALLBACK', 'Untag', '!this.tag(false)')

!menu = !this.newMenu('settingsMenu')
!menu.add('TOGGLE', 'Label', '!this.tag(')
!menu.add('TOGGLE', 'Detail', '!this.tag(')

-- Delete menu
!menu = !this.newMenu('deleteMenu')
!menu.add('CALLBACK', 'Selected', '!this.delete(''selected'')')
!menu.add('separator')
!menu.add('CALLBACK', 'All current aid type', '!this.delete(''alltype'')')
!menu.add('CALLBACK', 'All aid types', '!this.delete(''everything'')')

-- Define Permissible Aid elements


!dText[1] = 'Lines'
!rText[1] = 'lines'
!dText[2] = 'Circles'
!rText[2] = 'circles'
!dText[3] = 'Planes'
!rText[3] = 'planes'
!dText[4] = 'Working Points'
!rText[4] = 'points'
!dText[5] = 'Linear Grids'
!rText[5] = 'linearGrids'
!dText[6] = 'Radial Grids'
!rText[6] = 'radialGrids'
!dText[7] = 'Plant Grids'
!rText[7] = 'plantGrids'
!this.type.dText = !dText
!this.type.rText = !rText

!this.label = true
!this.detail = false

!this.settingsMenu.select('Label', !this.label)
!this.settingsMenu.select('Detail', !this.detail)

endmethod
-- End of method definition for .aidItemList()

------------------------------------------------------------------------
--
-- Method: initialise
--
-- Description:
-- Initialisation for form
--
-- Method Type: Function/Procedure
-- Arguments:
-- [#] [R/RW] [Data Type] [Description]
-- Return:
-- [Data Type] [Description]
--
------------------------------------------------------------------------

define method .initialise()

-- Load list with selection


!this.selectType()

endmethod
-- End of method definition for .initialise()

------------------------------------------------------------------------
--
-- Method: setupMenus
--
-- Description:
-- Setup menus
--
-- Method Type: Function/Procedure
-- Arguments:
-- [#] [R/RW] [Data Type] [Description]
-- Return:
-- [Data Type] [Description]
--
------------------------------------------------------------------------

define method .setupMenus()

-- Make delete all of current type inactive


if(!!aidConstructors.attribute(!this.type.selection('RTEXT').upcase()).size() eq
0) then
!this.bar.setActive('Edit', false)
!this.bar.setActive('Display', false)
!this.deleteMenu.setActive('Selected', false)
else
!this.bar.setActive('Edit', true)
!this.bar.setActive('Display', true)

-- Make delete options inactive


if(!this.aids.selection().empty()) then

!this.deleteMenu.setActive('Selected', false)
!this.editMenu.setActive('Unselect', false)
!this.editMenu.setActive('Definition...', false)
else
!this.deleteMenu.setActive('Selected', true)
!this.editMenu.setActive('Definition...', true)
!this.editMenu.setActive('Unselect', true)
endif

-- Display the Limits option for grids only


!this.displayMenu.setActive('Limits', !
this.type.selection('RTEXT').upcase().match('GRID').gt(0))

endif

endmethod
-- End of method definition for .setupMenus()

------------------------------------------------------------------------
--
-- Method: string
--
-- Description:
-- Accessible description of form
--
-- Method Type: Function/Procedure
-- Arguments:
-- [#] [R/RW] [Data Type] [Description]
-- Return:
-- [Data Type] [Description]
-- STRING Return
--
------------------------------------------------------------------------

define method .string() is STRING

return 'Aid Construction List Form'

endmethod
-- End of method definition for .string() STRING

------------------------------------------------------------------------
--
-- Method: selectType
--
-- Description:
-- Select aid type
--
-- Method Type: Function/Procedure
-- Arguments:
-- [#] [R/RW] [Data Type] [Description]
-- Return:
-- [Data Type] [Description]
--
------------------------------------------------------------------------

define method .selectType()

-- Initialise Variables

-- Elements selected
!rText = !!aidConstructors.definedText(!this.type.selection('RTEXT').upcase())

-- If there are no entries, then set


if(!rText.size() eq 0) then
!dText[1] = '>> No "' & !this.type.selection() & '" defined <<'
!rText[1] = ''

-- Get all aid numbers


else
-- Loop through elements of list
do !i indices !rText
!text = !rText[!i] & ' - ' & !!aidNumbers.numbers[!rText[!
i].real()].coreObject().string().after(' ').trim()
handle any
!dText[!i] = !rText[!i] & ' - ' & 'Invalid definition'
elsehandle none
!dText[!i] = !text
endhandle

enddo
endif

!this.aids.dText = !dText
!this.aids.rText = !rText

-- Setup menus
!this.setupMenus()

endmethod
-- End of method definition for .selectType()

------------------------------------------------------------------------
--
-- Method: delete
--
-- Description:
-- Delete selected entries
--
-- Method Type: Function/Procedure
-- Arguments:
-- [#] [R/RW] [Data Type] [Description]
-- 1 R STRING Option :
-- ALLTYPE - delete all for current type
-- SELECTED - delete all selected
-- Return:
-- [Data Type] [Description]
--
------------------------------------------------------------------------

define method .delete(!option is STRING)

-- Select all
if(!option.upcase() eq 'SELECTED') then
!!aidConstructors.remove(!this.type.selection('RTEXT').upcase(),!
this.aids.selection())

-- All aids of current type


elseif (!option.upcase() eq 'ALLTYPE') then
!!aidConstructors.remove(!this.type.selection('RTEXT').upcase())

-- All aids
elseif (!option.upcase() eq 'EVERYTHING') then

!!aidConstructors.remove()
endif

-- Update list
!this.selectType()

endmethod
-- End of method definition for .delete(STRING)
------------------------------------------------------------------------
--
-- Method: select
--
-- Description:
-- Select entry
--
-- Method Type: Function/Procedure
-- Arguments:
-- [#] [R/RW] [Data Type] [Description]
-- Return:
-- [Data Type] [Description]
--
------------------------------------------------------------------------

define method .select(!dummyGadget is GADGET, !dummySelect is STRING)

-- Initialise Variables

-- Setup menus
!this.setupMenus()

endmethod
-- End of method definition for .select(GADGET, STRING)

------------------------------------------------------------------------
--
-- Method: selectAll
--
-- Description:
-- Select all elements in current list
--
-- Method Type: Function/Procedure
-- Arguments:
-- [#] [R/RW] [Data Type] [Description]
-- Return:
-- [Data Type] [Description]
--
------------------------------------------------------------------------

define method .selectAll()

-- Select all entries


!array = !this.aids.rText

!this.aids.select('RTEXT', !array)

-- Setup menus
!this.setupMenus()

endmethod
-- End of method definition for .selectAll()

------------------------------------------------------------------------
--
-- Method: unselect
--
-- Description:
-- Unselected, selected entries
--
-- Method Type: Function/Procedure
-- Arguments:
-- [#] [R/RW] [Data Type] [Description]
-- Return:
-- [Data Type] [Description]
--
------------------------------------------------------------------------

define method .unSelect()

-- Unselect entries
!this.aids.clearSelection()

-- Setup menus
!this.setupMenus()

endmethod
-- End of method definition for .unSelect()

------------------------------------------------------------------------
--
-- Method: visible
--
-- Description:
-- Remove selected entries from the list
--
-- Method Type: Function/Procedure
-- Arguments:
-- [#] [R/RW] [Data Type] [Description]
-- 1 R BOOLEAN Visible state
-- Return:
-- [Data Type] [Description]
--
------------------------------------------------------------------------

define method .visible(!state is BOOLEAN)

-- Is there any selections


!selection = !this.aids.selection()

-- Set Visibility flag


do !i indices !selection
!!aidNumbers.numbers[!selection[!i].real()].visible = !state
handle any
elsehandle none
!!aidNumbers.numbers[!selection[!i].real()].draw(!selection[!i].real())
handle any
endhandle
endhandle
enddo

endmethod
-- End of method definition for .visible(BOOLEAN)

------------------------------------------------------------------------
--
-- Method: limits
--
-- Description:
-- Set view limits to selected entries from the list
--
-- Method Type: Function/Procedure
-- Arguments:
-- [#] [R/RW] [Data Type] [Description]
-- Return:
-- [Data Type] [Description]
--
------------------------------------------------------------------------

define method .limits()

-- Is there any selections


!selection = !this.aids.selection()

-- Set Visibility flag


do !i indices !selection
!!aidNumbers.numbers[!selection[!i].real()].visible = true
handle any
elsehandle none
!!aidNumbers.numbers[!selection[!i].real()].draw(!selection[!i].real())
handle any
endhandle
endhandle

!object = !!aidNumbers.numbers[!selection[!i].real()]
!objectType = !object.objectType()
if (!objectType inset ('GPHLINEARGRID','GPHRADIALGRID','GPHPLANTGRID')) then
-- Current Data
!position = !object.grid.position.wrt(world)

if (!objectType eq 'GPHRADIALGRID') then


-- Get a rough volume
!maxRadius = 0mm
do !j indices !object.grid.radii
!maxRadius = (max(!object.grid.radii[!j], !maxRadius))
enddo
!maxValue = !maxRadius
!minValue = !maxValue
elseif (!objectType eq 'GPHLINEARGRID') then
-- Get a rough volume
!maxX = !object.grid.xSpacing * !object.x / 2
!maxY = !object.grid.ySpacing * !object.y / 2
if (!maxX gt !maxY) then
!maxValue = !maxX
else
!maxValue = !maxY
endif
!minValue = !maxValue
elseif (!objectType eq 'GPHPLANTGRID') then
-- Get a rough volume
-- Add all the X spacings
!totalXPositive = 0mm
!totalXNegative = 0mm
do !j indices !object.grid.xSpacings
if (!object.grid.xSpacings[!j] gt 0mm) then
!totalXPositive = (!totalXPositive + !object.grid.xSpacings[!j])
else
!totalXNegative = (!totalXNegative + !object.grid.xSpacings[!j])
endif
enddo
!totalYPositive = 0mm
!totalYNegative = 0mm
do !j indices !object.grid.ySpacings
if (!object.grid.ySpacings[!j] gt 0mm) then
!totalYPositive = (!totalYPositive + !object.grid.ySpacings[!j])
else
!totalYNegative = (!totalYNegative + !object.grid.ySpacings[!j])
endif
enddo
!maxX = (max(!totalXPositive, !totalXNegative))
!maxY = (max(!totalYPositive, !totalYNegative))
if (!maxX gt !maxY) then
!maxValue = !maxX
else
!maxValue = !maxY
endif
!minX = (min(!totalXPositive, !totalXNegative))
!minY = (min(!totalYPositive, !totalYNegative))
if (!minX lt !minY) then
!minValue = !minX
else
!minValue = !minY
endif
endif

if (!i eq 1) then
!minumumEast = !position.east
!minumumNorth = !position.north
!minumumUp = !position.up
!maximumEast = !position.east
!maximumNorth = !position.north
!maximumUp = !position.up
endif

!fromPosition = !position
!fromPosition.east = (min((!fromPosition.east - !minValue), !minumumEast))
!fromPosition.north = (min((!fromPosition.north - !minValue), !minumumNorth))
!fromPosition.up = (min((!fromPosition.up - !minValue), !minumumUp))

!toPosition = !position
!toPosition.east = (max((!toPosition.east + !maxValue), !maximumEast))
!toPosition.north = (max((!toPosition.north + !maxValue), !maximumNorth))
!toPosition.up = (max((!toPosition.up + !maxValue), !maximumUp))

!minumumEast = !fromPosition.east
!minumumNorth = !fromPosition.north
!minumumUp = !fromPosition.up
!maximumEast = !toPosition.east
!maximumNorth = !toPosition.north
!maximumUp = !toPosition.up

!volume = object VOLUME(!fromPosition, !toPosition)


!!gphviews.limits(!!gphviews.views[1], !volume)
handle ANY
endhandle
endif
enddo

endmethod
-- End of method definition for .limits()

------------------------------------------------------------------------
--
-- Method: tag
--
-- Description:
-- Tag passed item
--
-- Method Type: Function/Procedure
-- Arguments:
-- [#] [R/RW] [Data Type] [Description]
-- 2 R BOOLEAN tag state
-- Return:
-- [Data Type] [Description]
--
------------------------------------------------------------------------

define method .tag(!state is BOOLEAN)

-- Select item
if(!state) then
!label = !this.label
!detail = !this.detail

-- Unselect item
else
!label = false
!detail = false
endif

-- Is there any selections


!selection = !this.aids.selection()

-- Set Visibility flag


do !i indices !selection
-- Set aid to tag
!!aidNumbers.numbers[!selection[!i].real()].tag = !label
!!aidNumbers.numbers[!selection[!i].real()].detail = !detail
handle any
elsehandle none
!!aidNumbers.numbers[!selection[!i].real()].draw(!selection[!i].real())
handle any
endhandle
endhandle
enddo

endmethod
-- End of method definition for .tag(BOOLEAN)

------------------------------------------------------------------------
--
-- Method: tag
--
-- Description:
-- Tag selection
--
-- Method Type: Function/Procedure
-- Arguments:
-- [#] [R/RW] [Data Type] [Description]
-- 1 R MENU Selected Menu
-- 2 R STRING Select State
-- Return:
-- [Data Type] [Description]
--
------------------------------------------------------------------------

define method .tag(!menu is MENU, !select is STRING)

-- Initialise Variables
!option = !menu.pickedField

-- State
if(!select eq 'SELECT') then
!state = true
else
!state = false
endif

-- Set relevant tag state


if(!option.upcase() eq 'LABEL') then
!this.label = !state
else
!this.detail = !state
endif

endmethod
-- End of method definition for .tag(MENU, STRING)

------------------------------------------------------------------------
--
-- Method: edit
--
-- Description:
-- Show graphic aid definition form
--
-- Method Type: Function/Procedure
-- Arguments:
-- [#] [R/RW] [Data Type] [Description]
-- Return:
-- [Data Type] [Description]
--
------------------------------------------------------------------------

define method .edit()

-- Is there any selections


!selection = !this.aids.selection()

-- Get last selected item


!selected = !selection[!selection.size()].real()

-- Edit definition
!!aidNumbers.numbers[!selected].edit(!selected)
endmethod
-- End of method definition for .edit()

------------------------------------------------------------------------
--
-- Method: save
--
-- Description:
-- Save graphics to file
--
-- Method Type: Function/Procedure
-- Arguments:
-- [#] [R/RW] [Data Type] [Description]
-- Return:
-- [Data Type] [Description]
--
------------------------------------------------------------------------

define method .save()

Using Namespace 'Aveva.Core.Presentation'


!browser = object PMLFILEBROWSER('save')

!browser.show('%AVEVA_DESIGN_USER%', '*.pmldat', 'Save Construction Graphics',


false, 'PMLDAT Files (*.pmldat)|*.pmldat', 1)

-- Initialise Variables
!file = !!file(!browser.file())

-- Load file into aid constructor system


if(!file.set()) then
!!aidConstructors.save(!file)
endif

endmethod
-- End of method definition for .save()

------------------------------------------------------------------------
--
-- Method: load
--
-- Description:
-- Load graphics from file
--
-- Method Type: Function/Procedure
-- Arguments:
-- [#] [R/RW] [Data Type] [Description]
-- Return:
-- [Data Type] [Description]
--
------------------------------------------------------------------------

define method .load()

-- Initialise Variables
!file = !!fileBrowser.file

-- Load file into aid constructor system


!!aidConstructors.load(!file)
-- Update list
!this.selectType()

endmethod
-- End of method definition for .load()

You might also like