MyCoordPageTranslate.cpp
上传用户:cding2008
上传日期:2007-01-03
资源大小:1812k
文件大小:4k
源码类别:
OpenGL
开发平台:
Visual C++
- /////////////////////////////////////////////////////////////////////////////
- // MyCoordPageTranslate.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
- /////////////////////////////////////////////////////////////////////////////
- // CMyCoordPageTranslate property page
- IMPLEMENT_DYNCREATE(CMyCoordPageTranslate, CPropertyPage)
- CMyCoordPageTranslate::CMyCoordPageTranslate() : CPropertyPage(CMyCoordPageTranslate::IDD)
- {
- //{{AFX_DATA_INIT(CMyCoordPageTranslate)
- m_fTranslateX = 0.0f;
- m_fTranslateY = 0.0f;
- m_fTranslateZ = 0.0f;
- //}}AFX_DATA_INIT
- }
- CMyCoordPageTranslate::~CMyCoordPageTranslate()
- {
- }
- void CMyCoordPageTranslate::DoDataExchange(CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CMyCoordPageTranslate)
- DDX_Text(pDX, IDC_X, m_fTranslateX);
- DDX_Text(pDX, IDC_Y, m_fTranslateY);
- DDX_Text(pDX, IDC_Z, m_fTranslateZ);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CMyCoordPageTranslate, CPropertyPage)
- //{{AFX_MSG_MAP(CMyCoordPageTranslate)
- ON_EN_CHANGE(IDC_X, OnChangeX)
- ON_EN_CHANGE(IDC_Y, OnChangeY)
- ON_EN_CHANGE(IDC_Z, OnChangeZ)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMyCoordPageTranslate implementation
- void CMyCoordPageTranslate::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 object data
- // (The Camera and Points do NOT have a Translate data member)
- if(pDoc->m_bSelectCamera || pDoc->m_bSelectObjPoints)
- ResetDialogData();
- if(pWorld->m_pSelectedObj)
- pWorld->m_pSelectedObj->GetTranslation(&m_fTranslateX, &m_fTranslateY, &m_fTranslateZ);
- else
- ResetDialogData();
- // Dialog box is being initialized (FALSE)
- // or data is being retrieved (TRUE).
- UpdateData(FALSE);
- }
- void CMyCoordPageTranslate::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 Object.
- // (The Camera and Points do NOT have a Translate data member)
- if(pDoc->m_bSelectCamera)
- {
- // Do nothing
- }
- if(pDoc->m_bSelectParentObj || pDoc->m_bSelectChildObj)
- {
- if(pWorld->m_pSelectedObj)
- pWorld->m_pSelectedObj->SetTranslation(m_fTranslateX, m_fTranslateY, m_fTranslateZ);
- }
- if(pDoc->m_bSelectObjPoints)
- {
- // Do nothing
- }
- }
- void CMyCoordPageTranslate::ResetDialogData()
- {
- m_fTranslateX = 0.0f;
- m_fTranslateY = 0.0f;
- m_fTranslateZ = 0.0f;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMyCoordPageTranslate message handlers
- BOOL CMyCoordPageTranslate::OnInitDialog()
- {
- CPropertyPage::OnInitDialog();
- // 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 CMyCoordPageTranslate::OnChangeX()
- {
- // Enable the Apply Now button
- SetModified(TRUE);
- }
- void CMyCoordPageTranslate::OnChangeY()
- {
- // Enable the Apply Now button
- SetModified(TRUE);
- }
- void CMyCoordPageTranslate::OnChangeZ()
- {
- // Enable the Apply Now button
- SetModified(TRUE);
- }