3dPageCylinder.cpp
资源名称:gloop.zip [点击查看]
上传用户:shxiangxiu
上传日期:2007-01-03
资源大小:1101k
文件大小:5k
源码类别:
OpenGL
开发平台:
Visual C++
- /////////////////////////////////////////////////////////////////////////////
- // 3dPageCylinder.cpp : implementation file
- //
- // glOOP (OpenGL Object Oriented Programming library)
- // Copyright (c) Craig Fahrnbach 1997, 1998
- //
- // 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.
- //
- // This program is -not- in the public domain.
- //
- /////////////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "glOOP.h"
- #include "3dObjectDialog.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
- //////////////////////////////////////////////////////////////////
- // C3dPageCylinder
- IMPLEMENT_DYNCREATE(C3dPageCylinder, CPropertyPage)
- /////////////////////////////////////////////////////////////////////////////
- // C3dPageCylinder dialog construction
- C3dPageCylinder::C3dPageCylinder()
- : CPropertyPage(C3dPageCylinder::IDD)
- {
- m_bInitVertices = FALSE;
- //{{AFX_DATA_INIT(C3dPageCylinder)
- m_iSolid = -1;
- m_fTopRadius = 0.0f;
- m_fBaseRadius = 0.0f;
- m_szName = _T("");
- m_iSegments = 0;
- m_iSmooth = -1;
- //}}AFX_DATA_INIT
- }
- /////////////////////////////////////////////////////////////////////////////
- // C3dPageCylinder Destructor
- C3dPageCylinder::~C3dPageCylinder()
- {
- }
- void C3dPageCylinder::DoDataExchange(CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(C3dPageCylinder)
- DDX_Radio(pDX, IDC_RADIO_SOLID, m_iSolid);
- DDX_Text(pDX, IDC_HEIGHT, m_fHeight);
- DDX_Text(pDX, IDC_TOP_RADIUS, m_fTopRadius);
- DDX_Text(pDX, IDC_BASE_RADIUS, m_fBaseRadius);
- DDX_Text(pDX, IDC_NAME, m_szName);
- DDV_MaxChars(pDX, m_szName, 40);
- DDX_Text(pDX, IDC_SEGMENTS, m_iSegments);
- DDX_Radio(pDX, IDC_RADIO_SMOOTH, m_iSmooth);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(C3dPageCylinder, CPropertyPage)
- //{{AFX_MSG_MAP(C3dPageCylinder)
- ON_EN_CHANGE(IDC_BASE_RADIUS, OnChangeBaseRadius)
- ON_EN_CHANGE(IDC_HEIGHT, OnChangeHeight)
- ON_EN_CHANGE(IDC_TOP_RADIUS, OnChangeTopRadius)
- ON_EN_CHANGE(IDC_SEGMENTS, OnChangeSegments)
- ON_BN_CLICKED(IDC_RADIO_SOLID, OnRadioSolid)
- ON_BN_CLICKED(IDC_RADIO_SMOOTH, OnRadioSmooth)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // C3dPageCylinder message handlers
- BOOL C3dPageCylinder::OnInitDialog()
- {
- // Set our local values to the Objects' values
- m_szName = m_pObject->m_szName;
- m_fHeight = m_pObject->m_fHeight;
- m_fTopRadius = m_pObject->m_fTopRadius;
- m_fBaseRadius = m_pObject->m_fBaseRadius;
- m_iSegments = m_pObject->m_iSegments;
- m_iSolid = !m_pObject->m_bSolid;
- m_iSmooth = !m_pObject->m_bSmooth;
- CPropertyPage::OnInitDialog(); // let the base class do the default work
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void C3dPageCylinder::OnOK()
- {
- // Dialog box is being initialized (FALSE)
- // or data is being retrieved (TRUE).
- UpdateData(TRUE);
- // Set our Objects' values to the local values
- m_pObject->m_szName = m_szName;
- m_pObject->m_fHeight = m_fHeight;
- m_pObject->m_fTopRadius = m_fTopRadius;
- m_pObject->m_fBaseRadius = m_fBaseRadius;
- m_pObject->m_iSegments = m_iSegments;
- // Force the object to rebuild its' display list
- m_pObject->m_bBuildLists = TRUE;
- // Rebuild our objects vertices?
- if(m_bInitVertices)
- m_pObject->InitVertices();
- CPropertyPage::OnOK();
- }
- void C3dPageCylinder::OnRadioSolid()
- {
- // Toggle the radio selection
- if(m_pObject->m_bSolid) {
- m_pObject->m_bSolid = FALSE;
- m_iSolid = 1;
- }
- else {
- m_pObject->m_bSolid = TRUE;
- m_iSolid = 0;
- }
- // Initialize the Dialog Data (forces DoDataExchange)
- UpdateData(FALSE);
- }
- void C3dPageCylinder::OnRadioSmooth()
- {
- // Toggle the radio selection
- if(m_pObject->m_bSmooth) {
- m_pObject->m_bSmooth = FALSE;
- m_iSmooth = 1;
- }
- else {
- m_pObject->m_bSmooth = TRUE;
- m_iSmooth = 0;
- }
- // Initialize the Dialog Data (forces DoDataExchange)
- UpdateData(FALSE);
- }
- void C3dPageCylinder::OnChangeBaseRadius()
- {
- // User has modified the cylinders base radius, so set our vertice
- // initialization flag
- m_bInitVertices = TRUE;
- }
- void C3dPageCylinder::OnChangeTopRadius()
- {
- // User has modified the cylinders top radius, so set our vertice
- // initialization flag
- m_bInitVertices = TRUE;
- }
- void C3dPageCylinder::OnChangeHeight()
- {
- // User has modified the cylinders height, so set our vertice
- // initialization flag
- m_bInitVertices = TRUE;
- }
- void C3dPageCylinder::OnChangeSegments()
- {
- // User has modified the cylinders height, so set our vertice
- // initialization flag
- m_bInitVertices = TRUE;
- }