302 lines
12 KiB
C++
302 lines
12 KiB
C++
//ROMTEAM WorldEditor
|
|
////////////////////////////////////////////////////////////////////////////////////////
|
|
// File : DlgSphere3D.cpp : implementation file
|
|
// Author : Cristi Petrescu
|
|
// Date : 97.11
|
|
// Description :
|
|
////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
#include "stdafx.h"
|
|
#include "ACP_Base.h"
|
|
#include "incITF.h"
|
|
|
|
#undef CPA_WANTS_IMPORT
|
|
#undef CPA_EXPORT
|
|
#define CPA_WANTS_EXPORT
|
|
#include "OGD.h"
|
|
#undef CPA_WANTS_EXPORT
|
|
#ifndef CPA_WANTS_IMPORT
|
|
#define CPA_WANTS_IMPORT
|
|
#endif
|
|
|
|
#include "3Dinterf.hpp"
|
|
#include "DlgSph3D.hpp"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CDlgSphere3D dialog
|
|
|
|
|
|
CDlgSphere3D::CDlgSphere3D(Sphere3D *pSphere, CWnd* pParent /*=NULL*/)
|
|
: CDialog(CDlgSphere3D::IDD, pParent)
|
|
{
|
|
m_pSphere3D = pSphere;
|
|
|
|
//{{AFX_DATA_INIT(CDlgSphere3D)
|
|
m_Center_X = _T("");
|
|
m_Center_Y = _T("");
|
|
m_Center_Z = _T("");
|
|
m_Radius = _T("");
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
|
|
void CDlgSphere3D::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CDlgSphere3D)
|
|
DDX_Control(pDX, IDC_SLIDER_RADIUS, m_Slider_Radius);
|
|
DDX_Text(pDX, IDC_EDIT_CENTER_X, m_Center_X);
|
|
DDX_Text(pDX, IDC_EDIT_CENTER_Y, m_Center_Y);
|
|
DDX_Text(pDX, IDC_EDIT_CENTER_Z, m_Center_Z);
|
|
DDX_Text(pDX, IDC_EDIT_RADIUS, m_Radius);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CDlgSphere3D, CDialog)
|
|
//{{AFX_MSG_MAP(CDlgSphere3D)
|
|
ON_EN_CHANGE(IDC_EDIT_RADIUS, OnChangeEditRadius)
|
|
ON_EN_CHANGE(IDC_EDIT_CENTER_X, OnChangeEditCenterX)
|
|
ON_EN_CHANGE(IDC_EDIT_CENTER_Y, OnChangeEditCenterY)
|
|
ON_EN_CHANGE(IDC_EDIT_CENTER_Z, OnChangeEditCenterZ)
|
|
ON_WM_HSCROLL()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CDlgSphere3D message handlers
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Method :CDlgSphere3D - OnCancel
|
|
// Date : 97.11
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Description : set the initial radius value
|
|
// Author : Cristi Petrescu
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Modification :
|
|
// Date :
|
|
// By :
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
void CDlgSphere3D::OnCancel()
|
|
{
|
|
// TODO: Add extra cleanup here
|
|
|
|
m_pSphere3D -> SetRadius (& m_InitialRadius);
|
|
m_pSphere3D -> SetCenter (& m_InitialCenter);
|
|
|
|
CDialog::OnCancel();
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Method :CDlgSphere3D - RefreshSlider
|
|
// Date : 97.11
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Description : Refresh the position of the slider
|
|
// Author : Cristi Petrescu
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Modification :
|
|
// Date :
|
|
// By :
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
void CDlgSphere3D::RefreshSlider ()
|
|
{
|
|
m_Slider_Radius . SetOwner (this);
|
|
m_Slider_Radius . SetRange (0 , 150 , TRUE);
|
|
m_Slider_Radius . SetPos ((long) (m_pSphere3D -> GetRadius () * 100));
|
|
m_Slider_Radius . SetTicFreq (50);
|
|
|
|
UpdateData (FALSE);
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Method :CDlgSphere3D - RefreshRadiusFromSlider
|
|
// Date : 97.11
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Description : Refresh the radius of the sphere when the position of the slider has changed
|
|
// Author : Cristi Petrescu
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Modification :
|
|
// Date :
|
|
// By :
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
void CDlgSphere3D::RefreshRadiusFromSlider ()
|
|
{
|
|
UpdateData (TRUE);
|
|
|
|
MTH_tdxReal NewRadius = (float) (m_Slider_Radius . GetPos () / 100.0);
|
|
m_pSphere3D -> SetRadius (& NewRadius);
|
|
|
|
m_Radius . Format ("%.4g" , NewRadius);
|
|
UpdateData (FALSE);
|
|
|
|
RedrawBackground ();
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Method :CDlgSphere3D - RefreshData
|
|
// Date : 97.11
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Description : this function is called when the data need to be refreshed
|
|
// Author : Cristi Petrescu
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Modification :
|
|
// Date :
|
|
// By :
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
void CDlgSphere3D::RefreshData ()
|
|
{
|
|
// Init the variables on the screen
|
|
MTH3D_tdstVector Center = m_pSphere3D -> GetCenter ();
|
|
m_Center_X . Format ("%.4g" , Center . xX);
|
|
m_Center_Y . Format ("%.4g" , Center . xY);
|
|
m_Center_Z . Format ("%.4g" , Center . xZ);
|
|
m_Radius . Format ("%.4g" , m_pSphere3D -> GetRadius ());
|
|
RefreshSlider ();
|
|
|
|
UpdateData (FALSE); // Update the screen
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Method : CDlgSphere3D::RedrawBackground
|
|
// Date : 97.11
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Description : redraw the main view
|
|
// Author : Cristi Petrescu
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Modification :
|
|
// Date :
|
|
// By :
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
void CDlgSphere3D::RedrawBackground (void)
|
|
{
|
|
(((DEV_MultiDevice*)g_oFrameGest.ma_p_oWinArray[2][2]->GetActiveView())->DrawObject());
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Method :CDlgSphere3D - OnInitDialog
|
|
// Date : 97.11
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Description : this function is called when the dialog is created
|
|
// we get the initial values
|
|
// Author : Cristi Petrescu
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Modification :
|
|
// Date :
|
|
// By :
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
BOOL CDlgSphere3D::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
m_InitialRadius = m_pSphere3D -> GetRadius ();
|
|
m_InitialCenter = m_pSphere3D -> GetCenter ();
|
|
RefreshData ();
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Method :CDlgSphere3D - OnChangeEditCenterX
|
|
// Date : 97.11
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Description : this function is called when the user changes the X coordinate of the center
|
|
// we update the variable
|
|
// Author : Cristi Petrescu
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Modification :
|
|
// Date :
|
|
// By :
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
void CDlgSphere3D::OnChangeEditCenterX ()
|
|
{
|
|
UpdateData (TRUE); // Update variables from screen
|
|
m_pSphere3D -> SetCenterX ((float) atof (m_Center_X));
|
|
RedrawBackground ();
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Method :CDlgSphere3D - OnChangeEditCenterY
|
|
// Date : 97.11
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Description : this function is called when the user changes the Y coordinate of the center
|
|
// we update the variable
|
|
// Author : Cristi Petrescu
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Modification :
|
|
// Date :
|
|
// By :
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
void CDlgSphere3D::OnChangeEditCenterY ()
|
|
{
|
|
UpdateData (TRUE); // Update variables from screen
|
|
m_pSphere3D -> SetCenterY ((float) atof (m_Center_Y));
|
|
RedrawBackground ();
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Method :CDlgSphere3D - OnChangeEditCenterZ
|
|
// Date : 97.11
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Description : this function is called when the user changes the Z coordinate of the center
|
|
// we update the variable
|
|
// Author : Cristi Petrescu
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Modification :
|
|
// Date :
|
|
// By :
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
void CDlgSphere3D::OnChangeEditCenterZ ()
|
|
{
|
|
UpdateData (TRUE); // Update variables from screen
|
|
m_pSphere3D -> SetCenterZ ((float) atof (m_Center_Z));
|
|
RedrawBackground ();
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Method :CDlgSphere3D - OnChangeEditCenterZ
|
|
// Date : 97.11
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Description : this function is called when the user changes the Z coordinate of the center
|
|
// we update the variable
|
|
// Author : Cristi Petrescu
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Modification :
|
|
// Date :
|
|
// By :
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
void CDlgSphere3D::OnChangeEditRadius ()
|
|
{
|
|
UpdateData (TRUE); // Update variables from screen
|
|
GLI_tdxValue Radius = (float) atof (m_Radius);
|
|
m_pSphere3D -> SetRadius (& Radius);
|
|
RedrawBackground ();
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Method :CDlgSphere3D - OnHScroll
|
|
// Date : 97.11
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Description : Call when the slider is changed
|
|
// Author : Cristi Petrescu
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Modification :
|
|
// Date :
|
|
// By :
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
void CDlgSphere3D::OnHScroll(UINT nSBCode , UINT nPos , CScrollBar * pScrollBar)
|
|
{
|
|
if (pScrollBar == (void *) & m_Slider_Radius)
|
|
RefreshRadiusFromSlider ();
|
|
else
|
|
CDialog::OnHScroll (nSBCode , nPos , pScrollBar);
|
|
}
|