TCBDialog.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. // TCBDialog.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "SplineTest.h"
  22. #include "TCBDialog.h"
  23. #include "curve.h"
  24. #include "hermitespline.h"
  25. #include "catmullromspline.h"
  26. #include "cardinalspline.h"
  27. #include "tcbspline.h"
  28. #ifdef _DEBUG
  29. #define new DEBUG_NEW
  30. #undef THIS_FILE
  31. static char THIS_FILE[] = __FILE__;
  32. #endif
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CTCBDialog dialog
  35. CTCBDialog::CTCBDialog(CWnd* pParent,TCBSpline3DClass * curve,int key)
  36. : CDialog(CTCBDialog::IDD, pParent)
  37. {
  38. //{{AFX_DATA_INIT(CTCBDialog)
  39. // NOTE: the ClassWizard will add member initialization here
  40. //}}AFX_DATA_INIT
  41. Curve = curve;
  42. Key = key;
  43. }
  44. void CTCBDialog::DoDataExchange(CDataExchange* pDX)
  45. {
  46. CDialog::DoDataExchange(pDX);
  47. //{{AFX_DATA_MAP(CTCBDialog)
  48. // NOTE: the ClassWizard will add DDX and DDV calls here
  49. //}}AFX_DATA_MAP
  50. }
  51. BEGIN_MESSAGE_MAP(CTCBDialog, CDialog)
  52. //{{AFX_MSG_MAP(CTCBDialog)
  53. //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55. /////////////////////////////////////////////////////////////////////////////
  56. // CTCBDialog message handlers
  57. BOOL CTCBDialog::OnInitDialog()
  58. {
  59. CDialog::OnInitDialog();
  60. float t,c,b;
  61. Curve->Get_TCB_Params(Key,&t,&c,&b);
  62. SetDlgItemFloat(IDC_TENSION_EDIT,t);
  63. SetDlgItemFloat(IDC_CONTINUITY_EDIT,c);
  64. SetDlgItemFloat(IDC_BIAS_EDIT,b);
  65. return TRUE;
  66. }
  67. void CTCBDialog::OnOK()
  68. {
  69. float t,c,b;
  70. t = GetDlgItemFloat(IDC_TENSION_EDIT);
  71. c = GetDlgItemFloat(IDC_CONTINUITY_EDIT);
  72. b = GetDlgItemFloat(IDC_BIAS_EDIT);
  73. Curve->Set_TCB_Params(Key,t,c,b);
  74. CDialog::OnOK();
  75. }
  76. float CTCBDialog::GetDlgItemFloat(int controlid)
  77. {
  78. CString string;
  79. GetDlgItemText(controlid,string);
  80. return atof(string);
  81. }
  82. void CTCBDialog::SetDlgItemFloat(int controlid,float val)
  83. {
  84. CString string;
  85. string.Format("%.2f",val);
  86. SetDlgItemText(controlid,string);
  87. }