reman3/Rayman_X/cpa/tempgrp/OGD/src/DLGBOX3D.CPP

793 lines
36 KiB
C++

//ROMTEAM WorldEditor
////////////////////////////////////////////////////////////////////////////////////////
// File : DlgBox3D.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
#define CPA_WANTS_IMPORT
#include "3Dinterf.hpp"
#include "DlgBox3D.hpp"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgBox3D dialog
CDlgBox3D::CDlgBox3D (Box3D *pBox3D, CWnd * _pParent /*= NULL*/)
:CDialog (CDlgBox3D::IDD, _pParent)
{
m_pBox3D = pBox3D;
//{{AFX_DATA_INIT(CDlgBox3D)
m_Radio_Button = -1;
m_Check_Box_Cube = FALSE;
m_Edition_Zone_Center_X = _T("");
m_Edition_Zone_Center_Y = _T("");
m_Edition_Zone_Center_Z = _T("");
m_Edition_Zone_Height = _T("");
m_Edition_Zone_Length = _T("");
m_Edition_Zone_Width = _T("");
m_Edition_Zone_X_Maxi = _T("");
m_Edition_Zone_X_Mini = _T("");
m_Edition_Zone_Y_Maxi = _T("");
m_Edition_Zone_Y_Mini = _T("");
m_Edition_Zone_Z_Maxi = _T("");
m_Edition_Zone_Z_Mini = _T("");
//}}AFX_DATA_INIT
}
void CDlgBox3D::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgBox3D)
DDX_Radio(pDX, IDC_Radio_Button_Center, m_Radio_Button);
DDX_Check(pDX, IDC_Check_Box_Cube, m_Check_Box_Cube);
DDX_Text(pDX, IDC_Edition_Zone_Center_X, m_Edition_Zone_Center_X);
DDX_Text(pDX, IDC_Edition_Zone_Center_Y, m_Edition_Zone_Center_Y);
DDX_Text(pDX, IDC_Edition_Zone_Center_Z, m_Edition_Zone_Center_Z);
DDX_Text(pDX, IDC_Edition_Zone_Height, m_Edition_Zone_Height);
DDX_Text(pDX, IDC_Edition_Zone_Length, m_Edition_Zone_Length);
DDX_Text(pDX, IDC_Edition_Zone_Width, m_Edition_Zone_Width);
DDX_Text(pDX, IDC_Edition_Zone_X_Maxi, m_Edition_Zone_X_Maxi);
DDX_Text(pDX, IDC_Edition_Zone_X_Mini, m_Edition_Zone_X_Mini);
DDX_Text(pDX, IDC_Edition_Zone_Y_Maxi, m_Edition_Zone_Y_Maxi);
DDX_Text(pDX, IDC_Edition_Zone_Y_Mini, m_Edition_Zone_Y_Mini);
DDX_Text(pDX, IDC_Edition_Zone_Z_Maxi, m_Edition_Zone_Z_Maxi);
DDX_Text(pDX, IDC_Edition_Zone_Z_Mini, m_Edition_Zone_Z_Mini);
DDX_Control(pDX, IDC_Slider_Size, m_Slider_Size);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgBox3D, CDialog)
//{{AFX_MSG_MAP(CDlgBox3D)
ON_BN_CLICKED(IDC_Radio_Button_Center, On_Radio_Button_Center)
ON_BN_CLICKED(IDC_Radio_Button_Extrema, On_Radio_Button_Extrema)
ON_EN_CHANGE(IDC_Edition_Zone_X_Mini, On_Change_Edition_Zone_X_Mini)
ON_EN_CHANGE(IDC_Edition_Zone_Y_Mini, On_Change_Edition_Zone_Y_Mini)
ON_EN_CHANGE(IDC_Edition_Zone_Z_Mini, On_Change_Edition_Zone_Z_Mini)
ON_EN_CHANGE(IDC_Edition_Zone_X_Maxi, On_Change_Edition_Zone_X_Maxi)
ON_EN_CHANGE(IDC_Edition_Zone_Y_Maxi, On_Change_Edition_Zone_Y_Maxi)
ON_EN_CHANGE(IDC_Edition_Zone_Z_Maxi, On_Change_Edition_Zone_Z_Maxi)
ON_EN_CHANGE(IDC_Edition_Zone_Center_X, On_Change_Edition_Zone_Center_X)
ON_EN_CHANGE(IDC_Edition_Zone_Center_Y, On_Change_Edition_Zone_Center_Y)
ON_EN_CHANGE(IDC_Edition_Zone_Center_Z, On_Change_Edition_Zone_Center_Z)
ON_EN_CHANGE(IDC_Edition_Zone_Length, On_Change_Edition_Zone_Length)
ON_EN_CHANGE(IDC_Edition_Zone_Width, On_Change_Edition_Zone_Width)
ON_EN_CHANGE(IDC_Edition_Zone_Height, On_Change_Edition_Zone_Height)
ON_BN_CLICKED(IDC_Check_Box_Cube, On_Check_Box_Cube)
ON_WM_HSCROLL()
ON_BN_CLICKED(IDC_Button_Init, On_Button_Init)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - OnInitDialog
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : initialisation of the window
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL CDlgBox3D::OnInitDialog()
{
CDialog::OnInitDialog();
m_Radio_Button = 0; // we show the Center screen
m_InitialMini = m_pBox3D -> GetMinPoint (); //save the initial dimensions
m_InitialMaxi = m_pBox3D -> GetMaxPoint ();
RefreshData (); // Init the other variables
return TRUE;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - On_Radio_Button_Center
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : clic on the radio button Center : we show the fields for the center
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgBox3D::On_Radio_Button_Center ()
{
m_Radio_Button = 0;
// Fill the variables for the screen
MTH3D_tdstVector Center = m_pBox3D->GetCenter ();
m_Edition_Zone_Center_X . Format ("%.4g" , Center . xX);
m_Edition_Zone_Center_Y . Format ("%.4g" , Center . xY);
m_Edition_Zone_Center_Z . Format ("%.4g" , Center . xZ);
m_Edition_Zone_Length . Format ("%.4g" , m_pBox3D->GetLength ());
m_Edition_Zone_Width . Format ("%.4g" , m_pBox3D->GetWidth ());
m_Edition_Zone_Height . Format ("%.4g" , m_pBox3D->GetHeight ());
UpdateData (FALSE); // Update the screen
// Hide the items for the extrema screen
GetDlgItem (IDC_Frame_Mini) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Static_Text_X_Mini) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Static_Text_Y_Mini) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Static_Text_Z_Mini) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Edition_Zone_X_Mini) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Edition_Zone_Y_Mini) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Edition_Zone_Z_Mini) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Frame_Maxi) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Static_Text_X_Maxi) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Static_Text_Y_Maxi) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Static_Text_Z_Maxi) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Edition_Zone_X_Maxi) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Edition_Zone_Y_Maxi) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Edition_Zone_Z_Maxi) -> ShowWindow (SW_HIDE);
// Show the items for the Center screen
GetDlgItem (IDC_Frame_Center) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Static_Text_Center_X) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Static_Text_Center_Y) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Static_Text_Center_Z) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Static_Text_Length) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Static_Text_Width) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Static_Text_Height) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Edition_Zone_Center_X) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Edition_Zone_Center_Y) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Edition_Zone_Center_Z) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Edition_Zone_Length) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Edition_Zone_Width) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Edition_Zone_Height) -> ShowWindow (SW_SHOW);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - On_Radio_Button_Extrema
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : clic on the radio button Center : we show the fields for the extrema
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgBox3D::On_Radio_Button_Extrema ()
{
m_Radio_Button = 1;
// Fill the variables for the screen
MTH3D_tdstVector MinPoint = m_pBox3D->GetMinPoint ();
m_Edition_Zone_X_Mini . Format ("%.4g" , MinPoint . xX);
m_Edition_Zone_Y_Mini . Format ("%.4g" , MinPoint . xY);
m_Edition_Zone_Z_Mini . Format ("%.4g" , MinPoint . xZ);
MTH3D_tdstVector MaxPoint = m_pBox3D->GetMaxPoint ();
m_Edition_Zone_X_Maxi . Format ("%.4g" , MaxPoint . xX);
m_Edition_Zone_Y_Maxi . Format ("%.4g" , MaxPoint . xY);
m_Edition_Zone_Z_Maxi . Format ("%.4g" , MaxPoint . xZ);
UpdateData (FALSE); // Update the screen
// Hide the items for the Center screen
GetDlgItem (IDC_Frame_Center) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Static_Text_Center_X) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Static_Text_Center_Y) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Static_Text_Center_Z) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Static_Text_Length) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Static_Text_Width) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Static_Text_Height) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Edition_Zone_Center_X) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Edition_Zone_Center_Y) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Edition_Zone_Center_Z) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Edition_Zone_Length) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Edition_Zone_Width) -> ShowWindow (SW_HIDE);
GetDlgItem (IDC_Edition_Zone_Height) -> ShowWindow (SW_HIDE);
// Show the items for the extrema screen
GetDlgItem (IDC_Frame_Mini) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Static_Text_X_Mini) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Static_Text_Y_Mini) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Static_Text_Z_Mini) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Edition_Zone_X_Mini) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Edition_Zone_Y_Mini) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Edition_Zone_Z_Mini) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Frame_Maxi) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Static_Text_X_Maxi) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Static_Text_Y_Maxi) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Static_Text_Z_Maxi) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Edition_Zone_X_Maxi) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Edition_Zone_Y_Maxi) -> ShowWindow (SW_SHOW);
GetDlgItem (IDC_Edition_Zone_Z_Maxi) -> ShowWindow (SW_SHOW);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - On_Change_Edition_Zone_Center_X
// 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 CDlgBox3D::On_Change_Edition_Zone_Center_X ()
{
UpdateData (TRUE); // Update variables from screen
m_pBox3D -> SetCenterX ((float) atof (m_Edition_Zone_Center_X));
RedrawBackground ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - On_Change_Edition_Zone_Center_Y
// 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 CDlgBox3D::On_Change_Edition_Zone_Center_Y ()
{
UpdateData (TRUE); // Update variables from screen
m_pBox3D -> SetCenterY ((float) atof (m_Edition_Zone_Center_Y));
RedrawBackground ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - On_Change_Edition_Zone_Center_Z
// 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 CDlgBox3D::On_Change_Edition_Zone_Center_Z ()
{
UpdateData (TRUE); // Update variables from screen
m_pBox3D -> SetCenterZ ((float) atof (m_Edition_Zone_Center_Z));
RedrawBackground ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - On_Change_Edition_Zone_Length
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : this function is called when the user changes the length of the box : we update the variables
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgBox3D::On_Change_Edition_Zone_Length ()
{
UpdateData (TRUE); // Update variables from screen
float Length = (float) atof (m_Edition_Zone_Length);
BOOL CorrectValue = m_pBox3D -> SetLength (& Length);
if (m_IsACube) // If it is a cube, we must change width and height
{
m_Edition_Zone_Width = m_Edition_Zone_Height = m_Edition_Zone_Length;
CorrectValue &= m_pBox3D -> SetWidth (& Length);
CorrectValue &= m_pBox3D -> SetHeight (& Length);
UpdateData (FALSE); // Update the screen
}
// If one of the given value is not correct (negative), we refresh the display
if (! CorrectValue) RefreshData (TRUE);
RefreshSlider ();
RedrawBackground ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - On_Change_Edition_Zone_Width
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : this function is called when the user changes the width of the box : we update the variables
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgBox3D::On_Change_Edition_Zone_Width ()
{
UpdateData (TRUE); // Update variables from screen
float Width = (float) atof (m_Edition_Zone_Width);
BOOL CorrectValue = m_pBox3D -> SetWidth (& Width);
if (m_IsACube) // If it is a cube, we must change length and height
{
m_Edition_Zone_Length = m_Edition_Zone_Height = m_Edition_Zone_Width;
CorrectValue &= m_pBox3D -> SetLength (& Width);
CorrectValue &= m_pBox3D -> SetHeight (& Width);
UpdateData (FALSE); // Update the screen
}
// If one of the given value is not correct (negative), we refresh the display
if (! CorrectValue) RefreshData (TRUE);
RefreshSlider ();
RedrawBackground ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - On_Change_Edition_Zone_Height
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : this function is called when the user changes the height of the box : we update the variables
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgBox3D::On_Change_Edition_Zone_Height ()
{
UpdateData (TRUE); // Update variables from screen
float Height = (float) atof (m_Edition_Zone_Height);
BOOL CorrectValue = m_pBox3D -> SetHeight (& Height);
if (m_IsACube) // If it is a cube, we must change length and width
{
m_Edition_Zone_Length = m_Edition_Zone_Width = m_Edition_Zone_Height;
CorrectValue &= m_pBox3D -> SetLength (& Height);
CorrectValue &= m_pBox3D -> SetWidth (& Height);
UpdateData (FALSE); // Update the screen
}
// If one of the given value is not correct (negative), we refresh the display
if (! CorrectValue) RefreshData (TRUE);
RefreshSlider ();
RedrawBackground ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - On_Change_Edition_Zone_X_Mini
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : this function is called when the user changes the X coordinate of the min point
// we update the variable
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgBox3D::On_Change_Edition_Zone_X_Mini()
{
UpdateData (TRUE); // Update variables from screen
float X_Mini = (float) atof (m_Edition_Zone_X_Mini);
BOOL CorrectValue = m_pBox3D -> SetMinPointX (& X_Mini);
if (m_IsACube) // If it is a cube, we must change Y_Mini and Z_Mini too
{
float Y_Mini = (float) (atof (m_Edition_Zone_Y_Maxi) - atof (m_Edition_Zone_X_Maxi) + X_Mini);
float Z_Mini = (float) (atof (m_Edition_Zone_Z_Maxi) - atof (m_Edition_Zone_X_Maxi) + X_Mini);
m_pBox3D -> SetMinPointY (& Y_Mini);
m_pBox3D -> SetMinPointZ (& Z_Mini);
RefreshData (TRUE);
UpdateData (FALSE); // Update the screen
}
else if (! CorrectValue) RefreshData (TRUE);
RefreshSlider ();
RedrawBackground ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - On_Change_Edition_Zone_Y_Mini
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : this function is called when the user changes the Y coordinate of the min point
// we update the variable
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgBox3D::On_Change_Edition_Zone_Y_Mini()
{
UpdateData (TRUE); // Update variables from screen
float Y_Mini = (float) atof (m_Edition_Zone_Y_Mini);
BOOL CorrectValue = m_pBox3D -> SetMinPointY (& Y_Mini);
if (m_IsACube) // If it is a cube, we must change X_Mini and Z_Mini too
{
float X_Mini = (float) (atof (m_Edition_Zone_X_Maxi) - atof (m_Edition_Zone_Y_Maxi) + Y_Mini);
float Z_Mini = (float) (atof (m_Edition_Zone_Z_Maxi) - atof (m_Edition_Zone_Y_Maxi) + Y_Mini);
m_pBox3D -> SetMinPointX (& X_Mini);
m_pBox3D -> SetMinPointZ (& Z_Mini);
RefreshData (TRUE);
UpdateData (FALSE); // Update the screen
}
else if (! CorrectValue) RefreshData (TRUE);
RefreshSlider ();
RedrawBackground ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - On_Change_Edition_Zone_Z_Mini
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : this function is called when the user changes the Z coordinate of the min point
// we update the variable
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgBox3D::On_Change_Edition_Zone_Z_Mini()
{
UpdateData (TRUE); // Update variables from screen
float Z_Mini = (float) atof (m_Edition_Zone_Z_Mini);
BOOL CorrectValue = m_pBox3D -> SetMinPointZ (& Z_Mini);
if (m_IsACube) // If it is a cube, we must change X_Mini and Y_Mini too
{
float X_Mini = (float) (atof (m_Edition_Zone_X_Maxi) - atof (m_Edition_Zone_Z_Maxi) + Z_Mini);
float Y_Mini = (float) (atof (m_Edition_Zone_Y_Maxi) - atof (m_Edition_Zone_Z_Maxi) + Z_Mini);
m_pBox3D -> SetMinPointX (& X_Mini);
m_pBox3D -> SetMinPointY (& Y_Mini);
RefreshData (TRUE);
UpdateData (FALSE); // Update the screen
}
else if (! CorrectValue) RefreshData (TRUE);
RefreshSlider ();
RedrawBackground ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - On_Change_Edition_Zone_X_Maxi
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : this function is called when the user changes the X coordinate of the max point
// we update the variable
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgBox3D::On_Change_Edition_Zone_X_Maxi()
{
UpdateData (TRUE); // Update variables from screen
float X_Maxi = (float) atof (m_Edition_Zone_X_Maxi);
BOOL CorrectValue = m_pBox3D -> SetMaxPointX (& X_Maxi);
if (m_IsACube) // If it is a cube, we must change Y_Maxi and Z_Maxi too
{
float Y_Maxi = (float) (atof (m_Edition_Zone_Y_Mini) + X_Maxi - atof (m_Edition_Zone_X_Mini));
float Z_Maxi = (float) (atof (m_Edition_Zone_Z_Mini) + X_Maxi - atof (m_Edition_Zone_X_Mini));
m_pBox3D -> SetMaxPointY (& Y_Maxi);
m_pBox3D -> SetMaxPointZ (& Z_Maxi);
RefreshData (TRUE);
UpdateData (FALSE); // Update the screen
}
else if (! CorrectValue) RefreshData (TRUE);
RefreshSlider ();
RedrawBackground ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - On_Change_Edition_Zone_Y_Maxi
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : this function is called when the user changes the Y coordinate of the max point
// we update the variable
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgBox3D::On_Change_Edition_Zone_Y_Maxi()
{
UpdateData (TRUE); // Update variables from screen
float Y_Maxi = (float) atof (m_Edition_Zone_Y_Maxi);
BOOL CorrectValue = m_pBox3D -> SetMaxPointY (& Y_Maxi);
if (m_IsACube) // If it is a cube, we must change X_Maxi and Z_Maxi too
{
float X_Maxi = (float) (atof (m_Edition_Zone_X_Mini) + Y_Maxi - atof (m_Edition_Zone_Y_Mini));
float Z_Maxi = (float) (atof (m_Edition_Zone_Z_Mini) + Y_Maxi - atof (m_Edition_Zone_Y_Mini));
m_pBox3D -> SetMaxPointX (& X_Maxi);
m_pBox3D -> SetMaxPointZ (& Z_Maxi);
RefreshData (TRUE);
UpdateData (FALSE); // Update the screen
}
else if (! CorrectValue) RefreshData (TRUE);
RefreshSlider ();
RedrawBackground ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - On_Change_Edition_Zone_Z_Maxi
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : this function is called when the user changes the Z coordinate of the max point
// we update the variable
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgBox3D::On_Change_Edition_Zone_Z_Maxi()
{
UpdateData (TRUE); // Update variables from screen
float Z_Maxi = (float) atof (m_Edition_Zone_Z_Maxi);
BOOL CorrectValue = m_pBox3D -> SetMaxPointZ (& Z_Maxi);
if (m_IsACube) // If it is a cube, we must change X_Maxi and Y_Maxi too
{
float X_Maxi = (float) (atof (m_Edition_Zone_X_Mini) + Z_Maxi - atof (m_Edition_Zone_Z_Mini));
float Y_Maxi = (float) (atof (m_Edition_Zone_Y_Mini) + Z_Maxi - atof (m_Edition_Zone_Z_Mini));
m_pBox3D -> SetMaxPointX (& X_Maxi);
m_pBox3D -> SetMaxPointY (& Y_Maxi);
RefreshData (TRUE);
UpdateData (FALSE); // Update the screen
}
else if (! CorrectValue) RefreshData (TRUE);
RefreshSlider ();
RedrawBackground ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - On_Check_Box_Cube
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : this function is called when the user clic on the check box Cube
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgBox3D::On_Check_Box_Cube()
{
UpdateData (TRUE); // Update variables from screen
m_IsACube = m_Check_Box_Cube;
if (m_IsACube) // if the check box Cube is selected, then length, width and height must be equal
{
//Box3D * p = m_pBox3D; // pointer to the ZDx box object
GLI_tdxValue L = (m_pBox3D->GetLength () + m_pBox3D->GetWidth () + m_pBox3D->GetHeight ()) / 3;
m_pBox3D->SetLength (& L);
m_pBox3D->SetWidth (& L);
m_pBox3D->SetHeight (& L);
// update the screen
if (m_Radio_Button == 0) On_Radio_Button_Center ();
else On_Radio_Button_Extrema ();
RefreshSlider ();
RedrawBackground ();
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - RefreshSlider
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : Refresh the position of the slider
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgBox3D::RefreshSlider ()
{
double BoxAverageSize = (m_pBox3D -> GetLength () + m_pBox3D -> GetWidth () + m_pBox3D -> GetHeight ()) / 3.0;
m_Slider_Size . SetOwner (this);
m_Slider_Size . SetRange (0 , 150 , TRUE);
m_Slider_Size . SetPos ((long) (BoxAverageSize * 100));
m_Slider_Size . SetTicFreq (50);
UpdateData (FALSE);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - RefreshSizeFromSlider
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : Refresh the size of the box when the position of the slider has changed
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgBox3D::RefreshSizeFromSlider ()
{
UpdateData (TRUE);
float OldBoxAverageSize = (float) ((m_pBox3D -> GetLength () + m_pBox3D -> GetWidth () + m_pBox3D -> GetHeight ()) / 3.0);
float NewBoxAverageSize = (float) (m_Slider_Size . GetPos () / 100.0);
float Coef = NewBoxAverageSize / OldBoxAverageSize;
float NewLength = m_pBox3D -> GetLength () * Coef;
float NewWidth = m_pBox3D -> GetWidth () * Coef;
float NewHeight = m_pBox3D -> GetHeight () * Coef;
m_pBox3D -> SetLength (& NewLength);
m_pBox3D -> SetWidth (& NewWidth);
m_pBox3D -> SetHeight (& NewHeight);
RefreshData (TRUE);
RedrawBackground ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - RefreshData
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : this function is called when the data need to be refreshed (because of a Undo, for instance)
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgBox3D::RefreshData (BOOL _bKeepCube)
{
// Init the variables
if (! _bKeepCube) m_Check_Box_Cube = m_IsACube = FALSE;
// Init the variables on the screen
if (m_Radio_Button == 0) On_Radio_Button_Center ();
else On_Radio_Button_Extrema ();
RefreshSlider ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - RefreshData
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : this function is called when the data need to be refreshed (because of a Undo, for instance)
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgBox3D::RefreshData ()
{
RefreshData (FALSE);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - OnHScroll
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : Call when the slider is changed
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgBox3D::OnHScroll(UINT nSBCode , UINT nPos , CScrollBar * pScrollBar)
{
if (pScrollBar == (void *) & m_Slider_Size) RefreshSizeFromSlider ();
else CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - On_Button_Init
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : Call when the user clics on the Init button : we reinit the position and the size of the box
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgBox3D::On_Button_Init ()
{
m_pBox3D -> SetMinPoint (& m_InitialMini);
m_pBox3D -> SetMaxPoint (& m_InitialMaxi);
//m_pBox3D -> SetMinPoint (& m_FatherMinPoint);
RefreshData ();
RedrawBackground ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : void CDlgCone3D::RedrawBackground
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : redraws the main view.
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgBox3D::RedrawBackground (void)
{
(((DEV_MultiDevice*)g_oFrameGest.ma_p_oWinArray[2][2]->GetActiveView())->DrawObject());
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :CDlgBox3D - OnCancel
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set the initial radius value
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CDlgBox3D::OnCancel()
{
m_pBox3D -> SetMinPoint (& m_InitialMini);
m_pBox3D -> SetMaxPoint (& m_InitialMaxi);
//m_pBox3D -> SetMinPoint (& m_FatherMinPoint);
CDialog::OnCancel();
}