Вставка Таблицы дополнительных параметров ж/д линии

Автор Тема: Вставка Таблицы дополнительных параметров ж/д линии  (Прочитано 1929 раз)

0 Пользователей и 1 Гость просматривают эту тему.

Оффлайн soloviewsergАвтор темы

  • ADN
  • *
  • Сообщений: 8
  • Карма: 2
    • soloviewserg.ru
Прошу не судить строго за "модульно-функциональный" стиль кода, т.к. он написан 11 лет назад. Между тем задачи прямая и предметной области решены.
Код - vb.net [Выбрать]
  1. Friend Sub ComputeAndDrawAdvancedParamTable()
  2.  
  3.             If pDrawAdvancedParamTableFlag = True Then
  4.                 Try
  5.                     Dim alEntity As IAeccAlignmentEntity
  6.                     Dim aTangent As IAeccAlignmentTangent, aSpiral As IAeccAlignmentSpiral, aArc As IAeccAlignmentArc
  7.                     Dim aSCSGroup As IAeccAlignmentSCSGroup, aEntities As IAeccAlignmentEntities, spiralIn As IAeccAlignmentSpiral, spiralOut As IAeccAlignmentSpiral
  8.                     Dim spiralInLength As Double, spiralInDelta As Double, spiralOutLength As Double, spiralOutDelta As Double
  9.                     Dim allTangentsLength As Double, allSCSGroupLength As Double, allOfDownradius1SCSGroupLength As Double
  10.                     Dim allOfradius2SCSGroupLength As Double, allSCSGroupAngle As Double, summOfHeightForward As Double, summOfHeightReverse As Double, allOfgradientLength As Double
  11.                     Dim index As Int32
  12.  
  13.                     index = 0 : allTangentsLength = 0 : allSCSGroupLength = 0 : allOfDownradius1SCSGroupLength = 0 : allOfradius2SCSGroupLength = 0 : allSCSGroupAngle = 0 : allOfgradientLength = 0
  14.                     aEntities = curAlignment.Entities
  15.                     dlgMain.pb1.Value = 0 : dlgMain.pb1.Refresh()
  16.  
  17.                     For index = 0 To aEntities.Count - 1
  18.  
  19.                         alEntity = aEntities.Item(index)
  20.                         Select Case alEntity.Type
  21.                             Case AeccAlignmentEntityType.aeccArc
  22.                                 aArc = alEntity
  23.                                 allSCSGroupLength = allSCSGroupLength + aArc.Length
  24.  
  25.                                 If aEntities.EntityAtId(alEntity.EntityBefore).Type = AeccAlignmentEntityType.aeccSpiral Then
  26.                                     spiralIn = aEntities.EntityAtId(alEntity.EntityBefore)
  27.                                     spiralInLength = spiralIn.Length
  28.                                     spiralInDelta = spiralIn.Delta
  29.                                 Else
  30.                                     spiralInLength = 0
  31.                                     spiralInDelta = 0
  32.                                 End If
  33.                                 If aEntities.EntityAtId(alEntity.EntityAfter).Type = AeccAlignmentEntityType.aeccSpiral Then
  34.                                     spiralOut = aEntities.EntityAtId(alEntity.EntityAfter)
  35.                                     spiralOutLength = spiralOut.Length
  36.                                     spiralOutDelta = spiralOut.Delta
  37.                                 Else
  38.                                     spiralOutLength = 0
  39.                                     spiralOutDelta = 0
  40.                                 End If
  41.  
  42.                                 If aArc.Radius < pRadius1 Then
  43.                                     allOfDownradius1SCSGroupLength = allOfDownradius1SCSGroupLength + spiralInLength + aArc.Length + spiralOutLength
  44.                                 End If
  45.                                 If Abs(aArc.Radius - pRadius2) < (1 / (10 ^ pPrecisionAdvancedParamTable)) Then
  46.                                     allOfradius2SCSGroupLength = allOfradius2SCSGroupLength + spiralInLength + aArc.Length + spiralOutLength
  47.                                 End If
  48.                                 allSCSGroupAngle = allSCSGroupAngle + spiralInDelta + aArc.Delta + spiralOutDelta
  49.                             Case AeccAlignmentEntityType.aeccSpiral
  50.                                 aSpiral = alEntity
  51.                                 allSCSGroupLength = allSCSGroupLength + aSpiral.Length
  52.                             Case AeccAlignmentEntityType.aeccTangent
  53.                                 aTangent = alEntity
  54.                                 allTangentsLength = allTangentsLength + aTangent.Length
  55.                             Case AeccAlignmentEntityType.aeccSpiralCurveSpiralGroup
  56.                                 aSCSGroup = alEntity
  57.                                 allSCSGroupLength = allSCSGroupLength + aSCSGroup.Length
  58.                                 If aSCSGroup.Arc.Radius < pRadius1 Then
  59.                                     allOfDownradius1SCSGroupLength = allOfDownradius1SCSGroupLength + aSCSGroup.Length
  60.                                 End If
  61.                                 If Abs(aSCSGroup.Arc.Radius - pRadius2) < (1 / (10 ^ pPrecisionAdvancedParamTable)) Then
  62.                                     allOfradius2SCSGroupLength = allOfradius2SCSGroupLength + aSCSGroup.Length
  63.                                 End If
  64.                                 allSCSGroupAngle = allSCSGroupAngle + aSCSGroup.Arc.Delta + aSCSGroup.SpiralIn.Delta + aSCSGroup.SpiralOut.Delta
  65.                             Case Else
  66.  
  67.                         End Select
  68.                         dlgMain.pb1.Value = CInt(((index + 1) / (aEntities.Count)) * 100) : dlgMain.pb1.Refresh()
  69.  
  70.                     Next index
  71.  
  72.                     index = 0 : summOfHeightForward = 0
  73.                     dlgMain.pb1.Value = 0 : dlgMain.pb1.Refresh()
  74.                     For index = 0 To curFGProfile.PVIs.Count - 1
  75.  
  76.                         If index + 2 <= curFGProfile.PVIs.Count Then
  77.                             If curFGProfile.PVIs.Item(index).Elevation < curFGProfile.PVIs.Item(index + 1).Elevation Then
  78.                                 summOfHeightForward = summOfHeightForward + (curFGProfile.PVIs.Item(index + 1).Elevation - curFGProfile.PVIs.Item(index).Elevation)
  79.                             End If
  80.  
  81.                             If Abs(curFGProfile.PVIs.Item(index).Elevation - curFGProfile.PVIs.Item(index + 1).Elevation) / (curFGProfile.PVIs.Item(index + 1).Station - curFGProfile.PVIs.Item(index).Station) > pGradient Then
  82.                                 allOfgradientLength = allOfgradientLength + (curFGProfile.PVIs.Item(index + 1).Station - curFGProfile.PVIs.Item(index).Station)
  83.                             End If
  84.  
  85.                         End If
  86.  
  87.                         dlgMain.pb1.Value = CInt(((index + 1) / (curFGProfile.PVIs.Count)) * 100) : dlgMain.pb1.Refresh()
  88.  
  89.                     Next index
  90.  
  91.                     index = 0 : summOfHeightReverse = 0
  92.                     dlgMain.pb1.Value = 0 : dlgMain.pb1.Refresh()
  93.                     For index = curFGProfile.PVIs.Count - 1 To 0 Step -1
  94.  
  95.                         If index - 1 >= 0 Then
  96.                             If curFGProfile.PVIs.Item(index).Elevation < curFGProfile.PVIs.Item(index - 1).Elevation Then
  97.                                 summOfHeightReverse = summOfHeightReverse + (curFGProfile.PVIs.Item(index - 1).Elevation - curFGProfile.PVIs.Item(index).Elevation)
  98.                             End If
  99.                         End If
  100.  
  101.                         dlgMain.pb1.Value = CInt(((index + 1) / (curFGProfile.PVIs.Count)) * 100) : dlgMain.pb1.Refresh()
  102.  
  103.                     Next index
  104.  
  105.                     insertionPointAdvancedParamTable(0) = minCurProfileViewExtPoint(0)
  106.                     insertionPointAdvancedParamTable(1) = minCurProfileViewExtPoint(1) - 5900 + pDeltaAdvancedParamTableY
  107.  
  108.                     Dim aTable As AcadTable
  109.                     aTable = ThisDrawing.ModelSpace.AddTable(insertionPointAdvancedParamTable, 8, 2, textHeightWorkingValue * 3.2, textHeightWorkingValue * 50)
  110.                     aTable.RegenerateTableSuppressed = True
  111.                     With aTable
  112.  
  113.                         .Layer = pLayerAdvancedParamTableName
  114.                         .HeaderSuppressed = True
  115.                         .TitleSuppressed = True
  116.  
  117.                         .SetColumnWidth(1, textHeightWorkingValue * 10)
  118.                         .SetTextHeight(0, textHeightWorkingValue)
  119.                         .SetTextHeight(1, textHeightWorkingValue)
  120.                         '.SetAlignment 0, acMiddleCenter
  121.                         .SetAlignment(1, AcCellAlignment.acMiddleCenter)
  122.                         '.StyleName = ThisDrawing.TextStyles.item(styleWorkingValueNameIndex).Name
  123.                         .SetTextStyle(0, ThisDrawing.TextStyles.Item(styleWorkingValueNameIndex).Name)
  124.                         .SetTextStyle(1, ThisDrawing.TextStyles.Item(styleWorkingValueNameIndex).Name)
  125.                         .SetText(0, 0, ResourceManagerMainShadow.GetString("Parameters:", curUICulture)) '"Показатели:"
  126.                         .SetText(1, 0, ResourceManagerMainShadow.GetString("Tangents length, m", curUICulture)) : .SetText(1, 1, CStr(FormatNumber(allTangentsLength, pPrecisionAdvancedParamTable, vbTrue, vbFalse, vbFalse))) '"Длина прямых, м"
  127.                         .SetText(2, 0, ResourceManagerMainShadow.GetString("Curves length, m", curUICulture)) : .SetText(2, 1, CStr(FormatNumber(allSCSGroupLength, pPrecisionAdvancedParamTable, vbTrue, vbFalse, vbFalse))) '"Длина кривых, м"
  128.                         .SetText(3, 0, ResourceManagerMainShadow.GetString("Including at radius less than", curUICulture) & " " & pRadius1 & " " & ResourceManagerMainShadow.GetString("m, m", curUICulture)) : .SetText(3, 1, CStr(FormatNumber(allOfDownradius1SCSGroupLength, pPrecisionAdvancedParamTable, vbTrue, vbFalse, vbFalse))) '"В том числе при радиусе менее" '"м, м"
  129.                         .SetText(4, 0, ResourceManagerMainShadow.GetString("Including at radius", curUICulture) & " " & pRadius2 & " " & ResourceManagerMainShadow.GetString("m, m", curUICulture)) : .SetText(4, 1, CStr(FormatNumber(allOfradius2SCSGroupLength, pPrecisionAdvancedParamTable, vbTrue, vbFalse, vbFalse))) '"В том числе при радиусе" '"м, м"
  130.  
  131.                         angleDegree = allSCSGroupAngle * (180 / 3.1415926535897931)
  132.                         angleMinute = (angleDegree - Int(angleDegree)) * 60
  133.  
  134.                         .SetText(5, 0, ResourceManagerMainShadow.GetString("The sum of the PI angles, degree", curUICulture)) : .SetText(5, 1, CStr(Int(angleDegree)) & ChrW(176) & CStr(-Int(-angleMinute)) & "'") '"Сумма углов поворота, град"
  135.                         .SetText(6, 0, ResourceManagerMainShadow.GetString("The sum of the heights be overcome - one way / return, m", curUICulture)) : .SetText(6, 1, CStr(FormatNumber(summOfHeightForward, pPrecisionAdvancedParamTable, vbTrue, vbFalse, vbFalse)) & "/" & CStr(FormatNumber(summOfHeightReverse, pPrecisionAdvancedParamTable, vbTrue, vbFalse, vbFalse))) '"Сумма преодолеваемых высот - туда/обратно, м"
  136.                         .SetText(7, 0, ResourceManagerMainShadow.GetString("The sum of the area lengths with gradient more than", curUICulture) & " " & pGradient & ResourceManagerMainShadow.GetString(", m", curUICulture)) : .SetText(7, 1, CStr(FormatNumber(allOfgradientLength, pPrecisionAdvancedParamTable, vbTrue, vbFalse, vbFalse))) '"Сумма длин участков с уклоном более" '", м"
  137.  
  138.                         .RegenerateTableSuppressed = False
  139.                         .RecomputeTableBlock(True)
  140.                     End With
  141.                 Catch ex As System.Exception
  142.                     BuildErrorMessage(ex, False)
  143.                 End Try
  144.             End If
  145.  
  146.         End Sub

Оффлайн Александр Ривилис

  • Administrator
  • *****
  • Сообщений: 13829
  • Карма: 1784
  • Рыцарь ObjectARX
  • Skype: rivilis
soloviewserg,
Строго судить не будем. :) Только уж очень тяжело читать код на VB.NET.
Не забывайте про правильное Форматирование кода на форуме
Создание и добавление Autodesk Screencast видео в сообщение на форуме
Если Вы задали вопрос и на форуме появился правильный ответ, то не забудьте про кнопку Решение

Оффлайн soloviewsergАвтор темы

  • ADN
  • *
  • Сообщений: 8
  • Карма: 2
    • soloviewserg.ru
То же говорят при hard переходе с vb.net на C(#,...). Дело привычки и опыта (Дизассемблированный MSIL трудно читается?)... А при наличии утилит типа Tangible Software Source Code Converters различия стираются...