reman3/Rayman_X/cpa/tempgrp/OGD/src/DlgAlt3D.cpp

455 lines
15 KiB
C++

////////////////////////////////////////////////////////////////////////////////////////
// File : DlgAlt3D.cpp : implementation file
// Author : Cristi Petrescu
// Date : 98.02
// 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 "DlgAlt3D.hpp"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgAltimap3D dialog
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : CDlgAltimap3D::CDlgAltimap3D
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : Constuctor for the dialog
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
CDlgAltimap3D::CDlgAltimap3D(Altimap3D *pAltimap3D,CWnd* pParent /*=NULL*/)
: CDialog(CDlgAltimap3D::IDD, pParent)
{
m_pAltimap3D = pAltimap3D;
m_bSquareOrientation = FALSE;
m_bSetLeft = FALSE;
m_bSetRight = FALSE;
//{{AFX_DATA_INIT(CDlgAltimap3D)
m_iNbY = 0;
m_SizeX = 0.0f;
m_SizeY = 0.0f;
m_iNbX = 0;
//}}AFX_DATA_INIT
}
void CDlgAltimap3D::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgAltimap3D)
DDX_Control(pDX, IDC_SET_ORIENTATION, m_btnSquareOrientation);
DDX_Control(pDX, IDC_SET_LEFT, m_btnSetLeft);
DDX_Control(pDX, IDC_SET_RIGHT, m_btnSetRight);
DDX_Control(pDX, IDC_SLIDER_SIZEY, m_Slider_SizeY);
DDX_Control(pDX, IDC_SLIDER_SIZEX, m_Slider_SizeX);
DDX_Control(pDX, IDC_SLIDER_NBY, m_Slider_NbY);
DDX_Control(pDX, IDC_SLIDER_NBX, m_Slider_NbX);
DDX_Text(pDX, IDC_NBY, m_iNbY);
DDV_MinMaxInt(pDX, m_iNbY, 2, 50);
DDX_Text(pDX, IDC_SIZEX, m_SizeX);
DDV_MinMaxFloat(pDX, m_SizeX, 1.e-002f, 15.f);
DDX_Text(pDX, IDC_SIZEY, m_SizeY);
DDV_MinMaxFloat(pDX, m_SizeY, 1.e-002f, 15.f);
DDX_Text(pDX, IDC_NBX, m_iNbX);
DDV_MinMaxInt(pDX, m_iNbX, 2, 50);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgAltimap3D, CDialog)
//{{AFX_MSG_MAP(CDlgAltimap3D)
ON_WM_HSCROLL()
ON_EN_KILLFOCUS(IDC_NBX, OnKillfocusNbx)
ON_EN_KILLFOCUS(IDC_NBY, OnKillfocusNby)
ON_EN_KILLFOCUS(IDC_SIZEX, OnKillfocusSizex)
ON_EN_KILLFOCUS(IDC_SIZEY, OnKillfocusSizey)
ON_BN_CLICKED(IDC_SET_ORIENTATION, OnSetOrientation)
ON_BN_CLICKED(IDC_SET_LEFT, OnSetLeft)
ON_BN_CLICKED(IDC_SET_RIGHT, OnSetRight)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgAltimap3D message handlers
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : CDlgAltimap3D::OnInitDialog
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : Initialize the dialog
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL CDlgAltimap3D::OnInitDialog()
{
CDialog::OnInitDialog();
m_iNbX = m_pAltimap3D -> GetWidth ();
m_iNbY = m_pAltimap3D -> GetDepth ();
m_SizeX = m_pAltimap3D -> GetSquareDimX () * m_iNbX;
m_SizeY = m_pAltimap3D -> GetSquareDimY () * m_iNbY;
RefreshSquare ();
RefreshData ();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : CDlgAltimap3D::OnKillfocusNbx
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : accept the nbx change
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgAltimap3D::OnKillfocusNbx()
{
UpdateData (TRUE);
RefreshData ();
m_pAltimap3D -> SetWidth (m_iNbX);
m_pAltimap3D -> SetSquareDimX (m_SizeX / m_iNbX);
M_GetMainDevice3D () -> DrawObject ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : CDlgAltimap3D::OnKillfocusNby
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : accept the nby change
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgAltimap3D::OnKillfocusNby()
{
UpdateData (TRUE);
RefreshData ();
m_pAltimap3D -> SetDepth (m_iNbY);
m_pAltimap3D -> SetSquareDimY (m_SizeY / m_iNbY);
M_GetMainDevice3D () -> DrawObject ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : CDlgAltimap3D::OnKillfocusSizex
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : accept the sizex change
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgAltimap3D::OnKillfocusSizex()
{
UpdateData (TRUE);
RefreshData ();
m_pAltimap3D -> SetSquareDimX (m_SizeX / m_iNbX);
M_GetMainDevice3D () -> DrawObject ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : CDlgAltimap3D::OnKillfocusSizey
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : accept the sizey change
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgAltimap3D::OnKillfocusSizey()
{
UpdateData (TRUE);
RefreshData ();
m_pAltimap3D -> SetSquareDimY (m_SizeY / m_iNbY);
M_GetMainDevice3D () -> DrawObject ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : CDlgAltimap3D::OnHScroll
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : Handle the scrollbars usage
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgAltimap3D::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
if (pScrollBar == (void *) & m_Slider_NbX)
{
UpdateData (TRUE);
m_iNbX = m_Slider_NbX . GetPos ();
UpdateData (FALSE);
m_pAltimap3D -> SetWidth (m_iNbX);
m_pAltimap3D -> SetSquareDimX (m_SizeX / m_iNbX);
M_GetMainDevice3D () -> DrawObject ();
}
else if (pScrollBar == (void *) & m_Slider_NbY)
{
UpdateData (TRUE);
m_iNbY = m_Slider_NbY . GetPos ();
UpdateData (FALSE);
m_pAltimap3D -> SetDepth (m_iNbY);
m_pAltimap3D -> SetSquareDimY (m_SizeY / m_iNbY);
M_GetMainDevice3D () -> DrawObject ();
}
else if (pScrollBar == (void *) & m_Slider_SizeX)
{
UpdateData (TRUE);
m_SizeX = (float) (m_Slider_SizeX . GetPos ()) / 100;
UpdateData (FALSE);
m_pAltimap3D -> SetSquareDimX (m_SizeX / m_iNbX);
M_GetMainDevice3D () -> DrawObject ();
}
else if (pScrollBar == (void *) & m_Slider_SizeY)
{
UpdateData (TRUE);
m_SizeY = (float) (m_Slider_SizeY . GetPos ()) / 100;
UpdateData (FALSE);
m_pAltimap3D -> SetSquareDimY (m_SizeY / m_iNbY);
M_GetMainDevice3D () -> DrawObject ();
}
else
CDialog::OnHScroll (nSBCode , nPos , pScrollBar);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : CDlgAltimap3D::RefreshData
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : sets the fields and the corresponding scrollbars from the member variables
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgAltimap3D::RefreshData()
{
m_Slider_NbX . SetOwner (this);
m_Slider_NbX . SetRange (2 , 50 , TRUE);
m_Slider_NbX . SetPos (m_iNbX);
m_Slider_NbX . SetTicFreq (1);
m_Slider_NbY . SetOwner (this);
m_Slider_NbY . SetRange (2 , 50 , TRUE);
m_Slider_NbY . SetPos (m_iNbY);
m_Slider_NbY . SetTicFreq (1);
m_Slider_SizeX . SetOwner (this);
m_Slider_SizeX . SetRange (1 , 1500 , TRUE);
m_Slider_SizeX . SetPos ((int) (m_SizeX * 100));
m_Slider_SizeX . SetTicFreq (50);
m_Slider_SizeY . SetOwner (this);
m_Slider_SizeY . SetRange (1 , 1500 , TRUE);
m_Slider_SizeY . SetPos ((int) (m_SizeY * 100));
m_Slider_SizeY . SetTicFreq (50);
UpdateData (FALSE);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : CDlgAltimap3D::OnSetOrientation
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : Square shape button pressed
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgAltimap3D::OnSetOrientation()
{
m_bSquareOrientation = !m_bSquareOrientation;
RefreshSquare ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : CDlgAltimap3D::OnSetLeft
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : left triangle of the square pressed
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgAltimap3D::OnSetLeft()
{
m_bSetLeft = !m_bSetLeft;
RefreshSquare ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : CDlgAltimap3D::OnSetRight
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : right triangle of the square pressed
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgAltimap3D::OnSetRight()
{
m_bSetRight = !m_bSetRight;
RefreshSquare ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : CDlgAltimap3D::RefreshSquare
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : draw the three square buttons
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgAltimap3D::RefreshSquare (void)
{
m_ucSquareType = 0;
if (m_bSquareOrientation)
{
if (m_bSetLeft)
{
m_ucSquareType |= 2;
// draw the left button, confusing names!
m_btnSetLeft . LoadBitmaps (IDB_LEFT_CLEAR_BOTTOM);
}
else
{
// draw the left button
m_btnSetLeft . LoadBitmaps (IDB_LEFT_SET_BOTTOM);
}
if (m_bSetRight)
{
m_ucSquareType |= 1;
// draw the right button
m_btnSetRight . LoadBitmaps (IDB_RIGHT_CLEAR_BOTTOM);
}
else
{
// draw the right button
m_btnSetRight . LoadBitmaps (IDB_RIGHT_SET_BOTTOM);
}
}
else
{
if (m_bSetLeft)
{
m_ucSquareType |= 4;
// draw the left button
m_btnSetLeft . LoadBitmaps (IDB_LEFT_CLEAR_TOP);
}
else
{
// draw the left button
m_btnSetLeft . LoadBitmaps (IDB_LEFT_SET_TOP);
}
if (m_bSetRight)
{
m_ucSquareType |= 8;
// draw the right button
m_btnSetRight . LoadBitmaps (IDB_RIGHT_CLEAR_TOP);
}
else
{
// draw the right button
m_btnSetRight . LoadBitmaps (IDB_RIGHT_SET_TOP);
}
}
// draw the main button
UINT uiBitmapID = 0;
switch (m_ucSquareType)
{
case 0:
uiBitmapID = IDB_SQUARE_00;
break;
case 1:
uiBitmapID = IDB_SQUARE_01;
break;
case 2:
uiBitmapID = IDB_SQUARE_02;
break;
case 3:
uiBitmapID = IDB_SQUARE_03;
break;
case 4:
uiBitmapID = IDB_SQUARE_04;
break;
case 8:
uiBitmapID = IDB_SQUARE_08;
break;
case 12:
uiBitmapID = IDB_SQUARE_12;
break;
default:
ASSERT (FALSE);
}
m_btnSquareOrientation . LoadBitmaps (uiBitmapID);
m_btnSetLeft . SizeToContent ();
m_btnSetRight . SizeToContent ();
m_btnSquareOrientation . SizeToContent ();
m_btnSetLeft . RedrawWindow ();
m_btnSetRight . RedrawWindow ();
m_btnSquareOrientation . RedrawWindow ();
//m_pAltimap3D -> SetSelectedAltimapSquare (m_ucSquareType);
}