MyCoordPageRotation.cpp
上传用户:cding2008
上传日期:2007-01-03
资源大小:1812k
文件大小:5k
源码类别:

OpenGL

开发平台:

Visual C++

  1. /////////////////////////////////////////////////////////////////////////////
  2. // MyCoordPageRotation.cpp : implementation file
  3. //
  4. // ModelMagic 3D and 'glOOP' (OpenGL Object Oriented Programming library)
  5. // Copyright (c) Craig Fahrnbach 1997, 1999
  6. //
  7. // OpenGL is a registered trademark of Silicon Graphics
  8. //
  9. //
  10. // This program is provided for educational and personal use only and
  11. // is provided without guarantee or warrantee expressed or implied.
  12. //
  13. // Commercial use is strickly prohibited without written permission
  14. // from ImageWare Development.
  15. //
  16. /////////////////////////////////////////////////////////////////////////////
  17. #include "stdafx.h"
  18. #include "ModelMagic3D.h"
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CMyCoordPageRotation property page
  26. IMPLEMENT_DYNCREATE(CMyCoordPageRotation, CPropertyPage)
  27. CMyCoordPageRotation::CMyCoordPageRotation() : CPropertyPage(CMyCoordPageRotation::IDD)
  28. {
  29. //{{AFX_DATA_INIT(CMyCoordPageRotation)
  30. m_fRotateX = 0.0f;
  31. m_fRotateY = 0.0f;
  32. m_fRotateZ = 0.0f;
  33. //}}AFX_DATA_INIT
  34. }
  35. CMyCoordPageRotation::~CMyCoordPageRotation()
  36. {
  37. }
  38. void CMyCoordPageRotation::DoDataExchange(CDataExchange* pDX)
  39. {
  40. CPropertyPage::DoDataExchange(pDX);
  41. //{{AFX_DATA_MAP(CMyCoordPageRotation)
  42. DDX_Text(pDX, IDC_X, m_fRotateX);
  43. DDX_Text(pDX, IDC_Y, m_fRotateY);
  44. DDX_Text(pDX, IDC_Z, m_fRotateZ);
  45. //}}AFX_DATA_MAP
  46. }
  47. BEGIN_MESSAGE_MAP(CMyCoordPageRotation, CPropertyPage)
  48. //{{AFX_MSG_MAP(CMyCoordPageRotation)
  49. ON_EN_CHANGE(IDC_X, OnChangeX)
  50. ON_EN_CHANGE(IDC_Y, OnChangeY)
  51. ON_EN_CHANGE(IDC_Z, OnChangeZ)
  52. //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CMyCoordPageRotation implementation
  56. void CMyCoordPageRotation::UpdateDialogData()
  57. {
  58. // Get a pointer to our Main Frame
  59. CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
  60. ASSERT_VALID(pFrame);
  61. // Get a pointer to our view's document
  62. CMyglDoc* pDoc = (CMyglDoc*)pFrame->m_pActiveView->GetDocument();
  63. ASSERT_VALID(pDoc);
  64. // Get a pointer to our document's 3dWorld
  65. C3dWorld* pWorld = pDoc->m_pWorld;
  66. ASSERT_VALID(pWorld);
  67. // Get the appropriate camera/object/point data
  68. // (Points do NOT have a Rotation data member)
  69. if(pDoc->m_bSelectCamera)
  70. {
  71. C3dCamera* pCamera = &pFrame->m_pActiveView->m_Camera;
  72. ASSERT_VALID(pCamera);
  73. pCamera->GetRotation(&m_fRotateX, &m_fRotateY, &m_fRotateZ);
  74. }
  75. if(pDoc->m_bSelectParentObj || pDoc->m_bSelectChildObj)
  76. {
  77. if(pWorld->m_pSelectedObj)
  78. pWorld->m_pSelectedObj->GetRotation(&m_fRotateX, &m_fRotateY, &m_fRotateZ);
  79. else
  80. ResetDialogData();
  81. }
  82. if(pDoc->m_bSelectObjPoints)
  83. ResetDialogData();
  84. // Dialog box is being initialized (FALSE)
  85. // or data is being retrieved (TRUE).
  86. UpdateData(FALSE);
  87. }
  88. void CMyCoordPageRotation::GetDialogData()
  89. {
  90. // Dialog box is being initialized (FALSE)
  91. // or data is being retrieved (TRUE).
  92. UpdateData(TRUE);
  93. // Get a pointer to our Main Frame
  94. CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
  95. ASSERT_VALID(pFrame);
  96. // Get a pointer to our view's document
  97. CMyglDoc* pDoc = (CMyglDoc*)pFrame->m_pActiveView->GetDocument();
  98. ASSERT_VALID(pDoc);
  99. // Get a pointer to our document's 3dWorld
  100. C3dWorld* pWorld = pDoc->m_pWorld;
  101. ASSERT_VALID(pWorld);
  102. // Now that we have the dialog data, copy to the selected Object.
  103. // (Points do NOT have a Rotation data member)
  104. if(pDoc->m_bSelectCamera)
  105. {
  106. C3dCamera* pCamera = &pFrame->m_pActiveView->m_Camera;
  107. ASSERT_VALID(pCamera);
  108. pCamera->SetRotation(m_fRotateX, m_fRotateY, m_fRotateZ);
  109. }
  110. if(pDoc->m_bSelectParentObj || pDoc->m_bSelectChildObj)
  111. {
  112. if(pWorld->m_pSelectedObj)
  113. pWorld->m_pSelectedObj->SetRotation(m_fRotateX, m_fRotateY, m_fRotateZ);
  114. }
  115. if(pDoc->m_bSelectObjPoints)
  116. {
  117. // Do nothing
  118. }
  119. }
  120. void CMyCoordPageRotation::ResetDialogData()
  121. {
  122. m_fRotateX = 0.0f;
  123. m_fRotateY = 0.0f;
  124. m_fRotateZ = 0.0f;
  125. }
  126. /////////////////////////////////////////////////////////////////////////////
  127. // CMyCoordPageRotation message handlers
  128. BOOL CMyCoordPageRotation::OnInitDialog() 
  129. {
  130. CPropertyPage::OnInitDialog();
  131. // Update the dialog data
  132. UpdateDialogData();
  133. return TRUE;  // return TRUE unless you set the focus to a control
  134.               // EXCEPTION: OCX Property Pages should return FALSE
  135. }
  136. void CMyCoordPageRotation::OnChangeX() 
  137. {
  138. // Enable the Apply Now button
  139. SetModified(TRUE);
  140. }
  141. void CMyCoordPageRotation::OnChangeY() 
  142. {
  143. // Enable the Apply Now button
  144. SetModified(TRUE);
  145. }
  146. void CMyCoordPageRotation::OnChangeZ() 
  147. {
  148. // Enable the Apply Now button
  149. SetModified(TRUE);
  150. }