Source


SUBMITTED BY: Guest

DATE: May 21, 2014, 10:35 a.m.

FORMAT: C++

SIZE: 5.5 kB

HITS: 782

  1. BOOL CForceGraphView::CreateGraph()
  2. {
  3. if ( m_pController == NULL )
  4. return FALSE;
  5. CStrip* pStrip = m_pController->GetActiveStrip();
  6. if ( pStrip == NULL )
  7. return FALSE;
  8. CStandPass* pPass = m_pController->GetActivePass();
  9. if ( pPass == NULL &&
  10. pStrip->GetMeasuredData() == NULL )
  11. return TRUE;
  12. C2DGraphSubSet * pLGraphSubSet = AddNew2DGraphSubSet(eTop | eLeft);
  13. C2DGraphSubSet * pRGraphSubSet = AddNew2DGraphSubSet(eTop | eRight);
  14. C2DGraphSet * pGraphSet = GetGraphSet();
  15. double dYMax = 0;
  16. _2D_POINTS_CREATE_STRUCT pcs;
  17. pcs.bDeletePoints = TRUE;
  18. pcs.bIncludeInLegend = TRUE;
  19. pcs.crColor = RGB(255, 0, 0);
  20. pcs.nMarkType = MT_NOMARK;
  21. pcs.nPenWidth = 25;
  22. pcs.pPointArray = new CObArray();
  23. pcs.strTitle = CStringEx(IDS_FORCE);
  24. if ( pPass != NULL )
  25. {
  26. for (int i = 0; i < pPass->GetForceCount(); i++)
  27. {
  28. pcs.pPointArray->Add(new C2DPoint(pPass->GetXPosition(i), pPass->GetForce(i) / 1e3));
  29. }
  30. pLGraphSubSet->AddPoints(pcs);
  31. pcs.pPointArray = new CObArray();
  32. pcs.strTitle = CStringEx(IDS_BENDING_FORCE);
  33. for (int i = 0; i < pPass->GetBendingForceCount(); i++)
  34. {
  35. pcs.pPointArray->Add(new C2DPoint(pPass->GetXPosition(i), pPass->GetBendingForce(i) / 1e3));
  36. }
  37. pRGraphSubSet->AddPoints(pcs);
  38. }
  39. CMeasuredData* pData = pStrip->GetMeasuredData();
  40. if ( pData != NULL )
  41. {
  42. CMeasuredDataMillPass* pMillPass = pStrip->GetMeasuredData()->GetMillPass(m_pController->GetActiveMillPassIndex());
  43. if ( pMillPass != NULL )
  44. {
  45. pcs.pPointArray = new CObArray();
  46. pcs.strTitle = CStringEx(IDS_FORCE);
  47. pcs.strTitle += _T(" S1");
  48. pcs.crColor = RGB(255, 0, 0);
  49. double dX = 0.;
  50. for ( auto point : pMillPass->GetAllPointsCL() )
  51. {
  52. CMeasuredDataMillPassPointCL* pPoint = point.second;
  53. if ( pPoint != NULL )
  54. pcs.pPointArray->Add( new C2DPoint(dX, pPoint->GetForceS1() / 1e3 ) );
  55. dX += ( 1.0 / ( pMillPass->GetPointCLCount() - 1 ) );
  56. }
  57. pLGraphSubSet->AddPoints( pcs );
  58. pcs.pPointArray = new CObArray();
  59. pcs.strTitle = CStringEx(IDS_FORCE);
  60. pcs.strTitle += _T(" S2");
  61. pcs.crColor = RGB(255, 0, 0);
  62. dX = 0.;
  63. for ( auto point : pMillPass->GetAllPointsCL() )
  64. {
  65. CMeasuredDataMillPassPointCL* pPoint = point.second;
  66. if ( pPoint != NULL )
  67. pcs.pPointArray->Add( new C2DPoint(dX, pPoint->GetForceS2() / 1e3 ) );
  68. dX += ( 1.0 / ( pMillPass->GetPointCLCount() - 1 ) );
  69. }
  70. pLGraphSubSet->AddPoints( pcs );
  71. pcs.pPointArray = new CObArray();
  72. pcs.strTitle = CStringEx(IDS_BENDING_FORCE);
  73. pcs.strTitle += _T(" S1");
  74. pcs.crColor = RGB(0, 0, 255);
  75. dX = 0.;
  76. for ( auto point : pMillPass->GetAllPointsCL() )
  77. {
  78. CMeasuredDataMillPassPointCL* pPoint = point.second;
  79. if ( pPoint != NULL )
  80. pcs.pPointArray->Add( new C2DPoint(dX, pPoint->GetBendingForceS1() / 1e3 ) );
  81. dX += ( 1.0 / ( pMillPass->GetPointCLCount() - 1 ) );
  82. }
  83. pLGraphSubSet->AddPoints( pcs );
  84. pcs.pPointArray = new CObArray();
  85. pcs.strTitle = CStringEx(IDS_BENDING_FORCE);
  86. pcs.strTitle += _T(" S2");
  87. pcs.crColor = RGB(0, 0, 255);
  88. dX = 0.;
  89. for ( auto point : pMillPass->GetAllPointsCL() )
  90. {
  91. CMeasuredDataMillPassPointCL* pPoint = point.second;
  92. if ( pPoint != NULL )
  93. pcs.pPointArray->Add( new C2DPoint(dX, pPoint->GetBendingForceS2() / 1e3 ) );
  94. dX += ( 1.0 / ( pMillPass->GetPointCLCount() - 1 ) );
  95. }
  96. pLGraphSubSet->AddPoints( pcs );
  97. }
  98. }
  99. CString strXDescription, strXUnits;
  100. strXDescription = CStringEx(IDS_LENGTH);
  101. pGraphSet->SetXAxisText(strXDescription);
  102. pGraphSet->SetXAxisMin((0.0));
  103. pGraphSet->SetXAxisMax((1.0));
  104. // Axis Y name
  105. CString strYDescription;
  106. strYDescription = CStringEx(IDS_FORCE);
  107. strYDescription += _T(" |[");
  108. strYDescription += CStringEx(IDS_UNIT_KN);
  109. strYDescription += _T("]");
  110. pLGraphSubSet->SetAxisText(strYDescription);
  111. strYDescription = CStringEx(IDS_BENDING_FORCE);
  112. strYDescription += _T(" |[");
  113. strYDescription += CStringEx(IDS_UNIT_KN);
  114. strYDescription += _T("]");
  115. pRGraphSubSet->SetAxisText(strYDescription);
  116. // Nastaveni fontu
  117. LOGFONT *lplf;
  118. lplf = pGraphSet->GetAxesFont();
  119. lplf->lfHeight = 8;
  120. #if defined(AFX_TARG_CSY) || defined(AFX_TARG_PLK)
  121. lplf->lfCharSet = EASTEUROPE_CHARSET;
  122. #endif
  123. #if defined(AFX_TARG_ENU)
  124. lplf->lfCharSet = DEFAULT_CHARSET;
  125. #endif
  126. pGraphSet->SetAxesFont( lplf );
  127. // Nastav typ grafu HorniLeve strane
  128. pGraphSet->SetTopLeftSubSet(pLGraphSubSet, TRUE );
  129. pGraphSet->SetTopRightSubSet(pRGraphSubSet, TRUE );
  130. // Povol kresleni mrizky
  131. pGraphSet->SetXAxisMainGridPenStyle( pGraphSet->XAxisAuxGridPenStyle() );
  132. pLGraphSubSet->SetMainGridPenStyle( pLGraphSubSet->GetAuxGridPenStyle() );
  133. pRGraphSubSet->SetMainGridPenStyle( pRGraphSubSet->GetAuxGridPenStyle() );
  134. pGraphSet->SetXAxisMainGrid( TRUE );
  135. pLGraphSubSet->SetMainGrid( TRUE );
  136. pRGraphSubSet->SetMainGrid( TRUE );
  137. return TRUE;
  138. }

comments powered by Disqus