DIAdem Help

Object: D2CurveTransformingContext

  • Updated2024-09-12
  • 2 minute(s) read

Object: D2CurveTransformingContext

The D2CurveTransformingContext object provides information about the 2D axis system, the worksheet, and the channels and their data type for the curve transformation in a 2D axis system in DIAdem REPORT. Access the REPORT objects such as the worksheet, the 2D axis system, and the curves in read-only mode.

Note  To test the example script, you must first save the second script and register it as a user command in the dialog box that opens when you select Settings»Extensions»User Commands.

The following example generates an axis system with two curves and assigns the user command MyOnCurveTransformation to the second curve:

Dim oMy2DAxisSystem, oMyPos, oMy2DCurveOrg, oMy2DCurveTrans
Call Report.NewLayout()
Call Data.Root.Clear()
Call DataFileLoad(DataReadPath & "Report_Data.tdm","TDM","")
Set oMy2DAxisSystem = Report.ActiveSheet.Objects.Add(eReportObject2DAxisSystem, "My2DAxisSystem")
Set oMyPos = oMy2DAxisSystem.Position.ByCoordinate
oMyPos.X1 = 20
oMyPos.X2 = 80
oMyPos.Y1 = 20
oMyPos.Y2 = 80
Set oMy2DCurveOrg = oMy2DaxisSystem.Curves2D.Add(e2DShapeLine, "MyOrgDCurve")
oMy2DCurveOrg.Shape.XChannel.Reference = "[1]/[1]"
oMy2DCurveOrg.Shape.YChannel.Reference = "[1]/[2]" 
Set oMy2DCurveTrans = oMy2DaxisSystem.Curves2D.Add(e2DShapeLine, "MyTransCurve")
oMy2DCurveTrans.Shape.XChannel.Reference = "[1]/[1]"
oMy2DCurveTrans.Shape.YChannel.Reference = "[1]/[2]" 
Call oMy2DCurveOrg.Shape.Settings.Line.Color.SetPredefinedColor(eColorIndexBlue)
Call oMy2DCurveTrans.Shape.Settings.Line.Color.SetPredefinedColor(eColorIndexRed)
oMy2DAxisSystem.Settings.UseCurveTransformation = TRUE
oMy2DCurveTrans.OnCurveTransformation = "MyOnCurveTransformation"
Call Report.Refresh()

The user command copies the x-values and smoothes the y-values:

Sub MyOnCurveTransformation(Context)
  Dim oMyDataContext
  Set oMyDataContext = Context.DataContext
  Select Case Context.DataType
    Case e2DCurveTransformDataTypeXY 
      Call ChnCopy  (oMyDataContext.XChannelNumberIn ,oMyDataContext.XChannelNumberOut) 'Copy the input channel into the output channel
      Call ChnSmooth(oMyDataContext.YChannelNumberIn, oMyDataContext.YChannelNumberOut, 100, "symmetric") 'Smooth the input channel and save the result as output channel
    Case e2DCurveTransformDataTypeXYY1 
      Call ChnCopy  (oMyDataContext.XChannelNumberIn ,oMyDataContext.XChannelNumberOut) 'Copy the input channel into the output channel
      Call ChnSmooth(oMyDataContext.YChannelNumberIn, oMyDataContext.YChannelNumberOut, 2, "symmetric") 'Smooth the input channel and save the result as output channel
      Call ChnSmooth(oMyDataContext.Y1ChannelNumberIn, oMyDataContext.Y1ChannelNumberOut, 2, "symmetric") 'Smooth the input channel and save the result as output channel
    Case e2DCurveTransformDataTypeCXCY 
      oMyDataContext.ConstXOut = oMyDataContext.ConstXIn + 2
      oMyDataContext.ConstYOut = oMyDataContext.ConstYIn + 2
  End Select 
End Sub