通过动画建立连接

动画对象在数据源和连接对象之间进行数据转换。动画对象在数据源和连接对象之间进行数据转换。下图说明了动画连接的概念。

动画连接举例

如需使用动画对话框建立线性动画连接:

  1. 双击一个矩形,动画对话框弹出。
  2. 选择尺寸标签并单击“高度”按钮,动画对话框展开。
  3. 从数据转换列表框中选择范围(Range),这将允许矩形的高度在数据源所定义的范围内变化。
  4. 从数据转换列表框中选择范围(Range),这将允许矩形的高度在数据源所定义的范围内变化。
  5. 单击“确定”。注意矩形现在有一个矩形动态对象,其中将一个数据源的值转换到该矩形的高度的比例变化。下面脚本使用线形动画对象在一个矩形垂直定位属性和一个数据源之间构造连接。

这段脚本位于名叫btnDirectConn的工具栏的Click事件中。

下面脚本使用线形动画对象在一个矩形垂直定位属性和一个数据源之间构造连接。这段脚本位于名叫btnDirectConn的工具栏的Click事件中。在本例中,Animations是这个画面的名称。有关使用脚本的方法和属性,即SetSource, Connect, DoesPropertyHaveTargets, 和 GetPropertyTargets的详细内容,请看iFIX自动化接口电子书中有关内容。

例: 利用脚本创建动画连接

Private Sub btnDirectConn_Click()

     Dim iRect As Object

     Dim iOval As Object

     Dim LinearObject As Object

     Dim strFullname As String

     Dim blnHasTargets As Boolean

     Dim lngStatus As Long

     Dim lngNumTargets As Long

     Dim lngIndex As Long

     Dim strPropertyName As String

     Dim strSource As String

     Dim vtTargets()

 

     'Create a rectangle and an oval

     Set iRect = Animations.BuildObject("rect")

     Set iOval = Animations.BuildObject("oval")

 

     'Set some positioning and size attributes on

     'the rectangle

     iRect.HorizontalPosition = 80

     iRect.VerticalPosition = 45

     iRect.Height = 5

     iRect.Width = 10

     iOval.HorizontalPosition = 60

     iOval.VerticalPosition = 35

     iOval.Height = 5

     iOval.Width = 10

     iRect.Commit

     iOval.Commit

 

     'Create a Linear animation object for the rectangle

     Set LinearObject = iRect.BuildObject("linear")

 

     'Set the source of the Linear animation object

     LinearObject.SetSource "AI1.F_CV", True

 

     'Specify the Linear animation object's minimum and

     'maximum Input and Output values

     LinearObject.LoInValue = 0

     LinearObject.LoOutValue = 0

     LinearObject.HiInValue = 100

     LinearObject.HiOutValue = 50

 

     'Set UseDelta to True to ensure that the base position

     'of the object will be added to the output value when

     'the Linear object evaluates. If UseDelta is set to

     'False, the output value would be absolute when the

     'Linear object evaluates

     LinearObject.UseDelta = True

 

     'Connect the rectangle's VerticalPosition property to

     'the output value of the Linear animation object

     strFullname = LinearObject.FullyQualifiedName & _
    ".OutputValue"

     iRect.Connect "VerticalPosition", strFullname, lngStatus

 

     'Create a string containing the fully qualified data

     'source for the rectangle's VerticalPosition property

     + iRect.Name + _ ".

 

     'Connect the oval's HorizontalFillPercentage property

     'to the rectangle's VerticalPosition property by using

     'the string created above as a data source

     iOval.Connect "HorizontalFillPercentage", strSource, _
    lngStatus

 

     'Once connected, you can verify that the Rectangle's

     'Vertical Position is being used as a data source for the

     'Oval's Horizontal Fill Percentage using the Target methods.

 

     'Now that there is a direct connection to the rectangle's

     'VerticalPosition property, retrieve information about

     'the objects that are using the VerticalPosition property

     'as a data source. This call will return if the property

     'is being used as a data source, how many objects are

     'using it as a data source, the status of the objects,

     'and the index of the object be passed to the

     'GetPropertyTargets method.

 

'NOTE: If you only want to determine the number of

     'objects using the property as a data source, you can use

     'the NumberOfTargets property instead.

 

     iRect.DoesPropertyHaveTargets "VerticalPosition", _

     blnHasTargets, lngNumTargets, lngStatus, lngIndex

 

     'Use the lngIndex value from the DoesPropertyHaveTargets

     'call to determine which property of the rectangle has

     'targets and to obtain a list of object names that have

     'built connections to this property.

 

     iRect.GetPropertyTargets lngIndex, strPropertyName, _

     vtTargets

 

End Sub

如何做...

您最近了解过 iFIX 吗 ?

查看最新版 iFIX 的所有新功能。

让 iFIX 帮助您提高效率,降低成本。