MyCoordPagePosition.cpp
上传用户:cding2008
上传日期:2007-01-03
资源大小:1812k
文件大小:5k
源码类别:
OpenGL
开发平台:
Visual C++
- /////////////////////////////////////////////////////////////////////////////
- // MyCoordPagePosition.cpp : implementation file
- //
- // ModelMagic 3D and 'glOOP' (OpenGL Object Oriented Programming library)
- // Copyright (c) Craig Fahrnbach 1997, 1999
- //
- // OpenGL is a registered trademark of Silicon Graphics
- //
- //
- // This program is provided for educational and personal use only and
- // is provided without guarantee or warrantee expressed or implied.
- //
- // Commercial use is strickly prohibited without written permission
- // from ImageWare Development.
- //
- /////////////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "ModelMagic3D.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMyCoordPagePosition property page
- IMPLEMENT_DYNCREATE(CMyCoordPagePosition, CPropertyPage)
- CMyCoordPagePosition::CMyCoordPagePosition() : CPropertyPage(CMyCoordPagePosition::IDD)
- {
- //{{AFX_DATA_INIT(CMyCoordPagePosition)
- m_fPositionX = 0.0f;
- m_fPositionY = 0.0f;
- m_fPositionZ = 0.0f;
- //}}AFX_DATA_INIT
- }
- CMyCoordPagePosition::~CMyCoordPagePosition()
- {
- }
- void CMyCoordPagePosition::DoDataExchange(CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CMyCoordPagePosition)
- DDX_Text(pDX, IDC_X, m_fPositionX);
- DDX_Text(pDX, IDC_Y, m_fPositionY);
- DDX_Text(pDX, IDC_Z, m_fPositionZ);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CMyCoordPagePosition, CPropertyPage)
- //{{AFX_MSG_MAP(CMyCoordPagePosition)
- ON_EN_CHANGE(IDC_X, OnChangeX)
- ON_EN_CHANGE(IDC_Y, OnChangeY)
- ON_EN_CHANGE(IDC_Z, OnChangeZ)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMyCoordPagePosition implementation
- void CMyCoordPagePosition::UpdateDialogData()
- {
- // Get a pointer to our Main Frame
- CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
- ASSERT_VALID(pFrame);
- // Get a pointer to our view's document
- CMyglDoc* pDoc = (CMyglDoc*)pFrame->m_pActiveView->GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- // Get the appropriate camera/object/point data
- if(pDoc->m_bSelectCamera)
- {
- C3dCamera* pCamera = &pFrame->m_pActiveView->m_Camera;
- ASSERT_VALID(pCamera);
- pCamera->GetOrigin(&m_fPositionX, &m_fPositionY, &m_fPositionZ);
- }
- if(pDoc->m_bSelectParentObj || pDoc->m_bSelectChildObj)
- {
- if(pWorld->m_pSelectedObj)
- pWorld->m_pSelectedObj->GetOrigin(&m_fPositionX, &m_fPositionY, &m_fPositionZ);
- else
- ResetDialogData();
- }
- if(pDoc->m_bSelectObjPoints)
- {
- if(pWorld->m_pSelectedPnt)
- pWorld->m_pSelectedPnt->GetOrigin(&m_fPositionX, &m_fPositionY, &m_fPositionZ);
- else
- ResetDialogData();
- }
- // Dialog box is being initialized (FALSE)
- // or data is being retrieved (TRUE).
- UpdateData(FALSE);
- }
- void CMyCoordPagePosition::GetDialogData()
- {
- // Dialog box is being initialized (FALSE)
- // or data is being retrieved (TRUE).
- UpdateData(TRUE);
- // Get a pointer to our Main Frame
- CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
- ASSERT_VALID(pFrame);
- // Get a pointer to our view's document
- CMyglDoc* pDoc = (CMyglDoc*)pFrame->m_pActiveView->GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- // Now that we have the dialog data, copy to the selected Camera, Object or Point
- if(pDoc->m_bSelectCamera)
- {
- C3dCamera* pCamera = &pFrame->m_pActiveView->m_Camera;
- ASSERT_VALID(pCamera);
- pCamera->SetOrigin(m_fPositionX, m_fPositionY, m_fPositionZ);
- }
- if(pDoc->m_bSelectParentObj || pDoc->m_bSelectChildObj)
- {
- if(pWorld->m_pSelectedObj)
- pWorld->m_pSelectedObj->SetOrigin(m_fPositionX, m_fPositionY, m_fPositionZ);
- }
- if(pDoc->m_bSelectObjPoints)
- {
- if(pWorld->m_pSelectedPnt)
- pWorld->m_pSelectedPnt->SetOrigin(m_fPositionX, m_fPositionY, m_fPositionZ);
- }
- }
- void CMyCoordPagePosition::ResetDialogData()
- {
- m_fPositionX = 0.0f;
- m_fPositionY = 0.0f;
- m_fPositionZ = 0.0f;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMyCoordPagePosition message handlers
- BOOL CMyCoordPagePosition::OnInitDialog()
- {
- CPropertyPage::OnInitDialog();
- // Get a pointer to our Main Frame
- CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
- if(pFrame)
- // Update the dialog data
- UpdateDialogData();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CMyCoordPagePosition::OnChangeX()
- {
- // Enable the Apply Now button
- SetModified(TRUE);
- }
- void CMyCoordPagePosition::OnChangeY()
- {
- // Enable the Apply Now button
- SetModified(TRUE);
- }
- void CMyCoordPagePosition::OnChangeZ()
- {
- // Enable the Apply Now button
- SetModified(TRUE);
- }