///////////////////////////////////////////////////
//
// Particles Generator Environment
//
///////////////////////////////////////////////////

#include "StdAfx.h"

#define D_MSPrtSrc_StructureDefine

#include "TPG_OEnv.hpp"

#include "_Minterf.hpp"
#include "TPG_Strg.hpp"
#include "TPG_ClBk.hpp"

#include "PRT.h"
#include "GAM.h"
#include "MTH.h"
#include "ErO.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


////////////////////////////////////////////////
// Constructor and Destructor
////////////////////////////////////////////////
CPA_PartGen_Environment::CPA_PartGen_Environment(CString _csName, PRT_tdstParticlesEnvironment *_p_stEnv, BOOL _bIsLoaded ) 
						: CPA_SaveObject( g_pclInterface, g_C_csPartGenEnvName, E_ss_Responsible )
{
	// Initialization for CPA_SaveObject
	SetSectionData( this );
	SetCallBackSave( m_s_fn_vCallBackSaveEnv );
	SetDataPath( C_szEffectPath );

	if ( fn_eRename(_csName) != E_mc_None )
		SetDefaultValidName();

	fn_vUpdateSectionName();

	m_pri_p_clGenerator = NULL;

	if( _bIsLoaded )
	{
		if ( _p_stEnv == NULL ) //created when new button is pressed : engine object is created
		{
			SetExistingSection( FALSE );
			ERROR_PREPARE_M
				(
					g_c_csPartGenModuleNameForErrors,
					"Creating a new environment",
					"CPA_PartGen_Environment::CPA_PartGen_Environment",
					E_ERROR_GRAVITY_FATAL,
					"the engine object is not allocated"
				);
			PRT_fn_vCreateParticlesEnvironment( &_p_stEnv );
			ERROR_ASSERT( _p_stEnv != NULL );
			fn_vUpdateData( (void*)_p_stEnv );
			m_pri_p_stEnv = _p_stEnv;

			m_pub_fn_vSetEnvType(PRT_C_ulSphereEnv);
			m_pub_fn_vSetBoxMin( 0.0, 0.0, 0.0 );
			m_pub_fn_vSetBoxMax( 1.0, 1.0, 1.0 );
			m_pub_fn_vSetSphereCenter( 0.0, 0.0, 0.0 );
		}
		else //created using linktable : engine object is loaded and used
		{
			SetExistingSection( TRUE );
			fn_vUpdateData( (void*)_p_stEnv );
			m_pri_p_stEnv = _p_stEnv;
		}
		m_pri_fn_vSetInternalPoints();
		m_pri_fn_vFillDataList();
	}
	else //created : engine object is not loaded now
	{
		fn_vUpdateData( NULL );
		m_pri_p_stEnv = NULL;
		SetExistingSection( TRUE );
	}

	SetAvailable( _bIsLoaded );
}

CPA_PartGen_Environment::~CPA_PartGen_Environment()
{
	fn_vNotifyUnSave();
}

//*********************************************
// Updates the pointer on engine object
void CPA_PartGen_Environment::m_pub_fn_vSetEnv( PRT_tdstParticlesEnvironment *_p_stEnv )
{
	fn_vUpdateData( (void*)_p_stEnv );
	m_pri_p_stEnv = _p_stEnv;
	SetAvailable( TRUE );

	m_pri_fn_vSetInternalPoints();
	m_pri_fn_vFillDataList();
}


void CPA_PartGen_Environment::m_pub_fn_vSetGenerator( CPA_PartGen_Generator *_p_clGen )
{
	m_pri_p_clGenerator = _p_clGen;
	m_pri_fn_vSetInternalPoints();
}


/////////////////////////////////////////
// virtual functions
/////////////////////////////////////////
long CPA_PartGen_Environment::GetDataType( void )
{
	return( 0 );
}

void* CPA_PartGen_Environment::GetData( void )
{
	return (void*)m_pri_p_stEnv;
}

CString CPA_PartGen_Environment::fn_csComputeReferencedSectionName(const CString _csNewName)
{
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	char szSectionName[ SCR_CV_ui_Cfg_MaxLenName ];
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	
	sprintf( szSectionName, "%s^%s:%s", C_szEnvironmentFileName, C_SectionPrtEnvDescription, (char *) LPCTSTR( _csNewName ) );
	return( szSectionName );
}


//****************************************************
// load the engine object if necessary
BOOL CPA_PartGen_Environment::m_pub_fn_vLoadIfUnloaded()
{
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	SCR_tdst_Cxt_Values				*p_stValues;
	PRT_tdstParticlesEnvironment	*p_stEnv;
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

	if ( fn_bIsAvailable() )
		return FALSE;

	p_stValues = SCR_fnp_st_RdL0_AnalyseSection((char *)LPCTSTR(GetReferencedSectionName()), SCR_CDF_uw_Anl_Normal);

	p_stEnv = (PRT_tdstParticlesEnvironment*)p_stValues->a_ulValues[0];
	ERROR_PREPARE_M
		(
			g_c_csPartGenModuleNameForErrors,
			"Loading an unloaded environment",
			"CPA_PartGen_Environment::m_pub_fn_vLoadIfUnloaded",
			E_ERROR_GRAVITY_FATAL,
			"the loaded engine object is null"
		);
	ERROR_ASSERT( p_stEnv != NULL );
	
	fn_vUpdateData( (void*) p_stEnv );
	m_pri_p_stEnv = p_stEnv;
	SetAvailable(TRUE);
	
	m_pri_fn_vFillDataList();

	return TRUE;
}


//////////////////////////////////////////////////
// Environment Type
void CPA_PartGen_Environment::m_pub_fn_vSetEnvType( short _wIndex )
{
	PRT_M_vSetTypeParticlesEnvironment( m_pri_p_stEnv, (unsigned long)_wIndex );
	fn_vNotifySave();
}

short CPA_PartGen_Environment::m_pub_fn_wGetEnvType()
{
	return (short)m_pri_p_stEnv->ulEnvType;
}


/////////////////////////////////////////////////
// Min Max for Box type
void CPA_PartGen_Environment::m_pri_fn_vSetInternalPoints()
{
	ERROR_PREPARE_M
		(
			g_c_csPartGenModuleNameForErrors,
			"Initialize internal data min max points and center for environment",
			"CPA_PartGen_Environment::m_pri_fn_vSetInternalPoints",
			E_ERROR_GRAVITY_FATAL,
			"Edited engine environment is NULL"
		);
	ERROR_ASSERT( m_pri_p_stEnv != NULL );

	if( m_pri_p_clGenerator == NULL )
	{
		MTH3D_M_vCopyVector( (&m_pri_stMinPoint), (&(m_pri_p_stEnv->stMinPoint)) );
		MTH3D_M_vCopyVector( (&m_pri_stMaxPoint), (&(m_pri_p_stEnv->stMaxPoint)) );
		MTH3D_M_vCopyVector( (&m_pri_stSphereCenter),   (&(m_pri_p_stEnv->stSphereCenter)) );
	}
	else
	{
		if( m_pri_p_clGenerator->m_pub_fn_bGetLinkToEnv() )
		{
			ERROR_PREPARE_M
				(
					g_c_csPartGenModuleNameForErrors,
					"Initialize internal data min max points and center for environment",
					"CPA_PartGen_Environment::m_pri_fn_vSetInternalPoints",
					E_ERROR_GRAVITY_FATAL,
					"Engine generator using the edited environment is NULL"
				);
			ERROR_ASSERT( m_pri_p_clGenerator->m_pri_hGenerator != NULL );
			MTH3D_M_vCopyVector( (&m_pri_stMinPoint), (&(m_pri_p_clGenerator->m_pri_hGenerator->stMinPoint)) );
			MTH3D_M_vCopyVector( (&m_pri_stMaxPoint), (&(m_pri_p_clGenerator->m_pri_hGenerator->stMaxPoint)) );
			MTH3D_M_vCopyVector( (&m_pri_stSphereCenter), (&(m_pri_p_clGenerator->m_pri_hGenerator->stMinPoint)) );
		}
		else
		{
			MTH3D_M_vCopyVector( (&m_pri_stMinPoint), (&(m_pri_p_stEnv->stMinPoint)) );
			MTH3D_M_vCopyVector( (&m_pri_stMaxPoint), (&(m_pri_p_stEnv->stMaxPoint)) );
			MTH3D_M_vCopyVector( (&m_pri_stSphereCenter),   (&(m_pri_p_stEnv->stSphereCenter)) );
		}
	}
}

void CPA_PartGen_Environment::m_pub_fn_vSetBoxMin( double _dMinX, double _dMinY, double _dMinZ )
{
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	MTH3D_tdstVector stBoxMin;
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	
	MTH3D_M_vSetVectorElements( &stBoxMin, MTH_M_xDoubleToReal(_dMinX), MTH_M_xDoubleToReal(_dMinY), MTH_M_xDoubleToReal(_dMinZ) );
	MTH3D_M_vCopyVector ( &((m_pri_p_stEnv)->stMinPoint), ( &stBoxMin ) );
	fn_vNotifySave();
}

double CPA_PartGen_Environment::m_pub_fn_dGetBoxMinX()
{
	return MTH_M_xRealToDouble( MTH3D_M_xGetXofVector( &m_pri_stMinPoint ) );
}

double CPA_PartGen_Environment::m_pub_fn_dGetBoxMinY()
{
	return MTH_M_xRealToDouble( MTH3D_M_xGetYofVector( &m_pri_stMinPoint ) );
}

double CPA_PartGen_Environment::m_pub_fn_dGetBoxMinZ()
{
	return MTH_M_xRealToDouble( MTH3D_M_xGetZofVector( &m_pri_stMinPoint ) );
}

void CPA_PartGen_Environment::m_pub_fn_vSetBoxMax( double _dMaxX, double _dMaxY, double _dMaxZ )
{
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	MTH3D_tdstVector stBoxMax;
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	
	MTH3D_M_vSetVectorElements( &stBoxMax, MTH_M_xDoubleToReal(_dMaxX), MTH_M_xDoubleToReal(_dMaxY), MTH_M_xDoubleToReal(_dMaxZ) );
	MTH3D_M_vCopyVector ( &((m_pri_p_stEnv)->stMaxPoint), ( &stBoxMax ) );
	fn_vNotifySave();
}

double CPA_PartGen_Environment::m_pub_fn_dGetBoxMaxX()
{
	return MTH_M_xRealToDouble( MTH3D_M_xGetXofVector( &m_pri_stMaxPoint ) );
}

double CPA_PartGen_Environment::m_pub_fn_dGetBoxMaxY()
{
	return MTH_M_xRealToDouble( MTH3D_M_xGetYofVector( &m_pri_stMaxPoint ) );
}

double CPA_PartGen_Environment::m_pub_fn_dGetBoxMaxZ()
{
	return MTH_M_xRealToDouble( MTH3D_M_xGetZofVector( &m_pri_stMaxPoint ) );
}

///////////////////////////////////////////////////////
// Center and Radius for Sphere type
void CPA_PartGen_Environment::m_pub_fn_vSetSphereCenter( double _dCenterX, double _dCenterY, double _dCenterZ )
{
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	MTH3D_tdstVector stSphereCenter;
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	
	MTH3D_M_vSetVectorElements( &stSphereCenter, MTH_M_xDoubleToReal(_dCenterX), MTH_M_xDoubleToReal(_dCenterY), MTH_M_xDoubleToReal(_dCenterZ) );
  	MTH3D_M_vCopyVector ( &((m_pri_p_stEnv)->stSphereCenter), ( &stSphereCenter ) );
	fn_vNotifySave();
}

double CPA_PartGen_Environment::m_pub_fn_dGetSphereCenterX()
{
	//ROMTEAM Bugs Correction (Cristian Stegaru 24/03/98)
	//	return MTH_M_xRealToDouble( MTH3D_M_xGetXofVector( &m_pri_stSphereCenter ) );
	return MTH_M_xRealToDouble (MTH3D_M_xGetXofVector (&m_pri_p_stEnv->stSphereCenter));
	//ENDROMTEAM Bugs Correction (Cristian Stegaru)
}

double CPA_PartGen_Environment::m_pub_fn_dGetSphereCenterY()
{
	//ROMTEAM Bugs Correction (Cristian Stegaru 24/03/98)
	//	return MTH_M_xRealToDouble( MTH3D_M_xGetYofVector( &m_pri_stSphereCenter ) );
	return MTH_M_xRealToDouble (MTH3D_M_xGetYofVector (&m_pri_p_stEnv->stSphereCenter));
	//ENDROMTEAM Bugs Correction (Cristian Stegaru)
}

double CPA_PartGen_Environment::m_pub_fn_dGetSphereCenterZ()
{
	//ROMTEAM Bugs Correction (Cristian Stegaru 24/03/98)
	//	return MTH_M_xRealToDouble( MTH3D_M_xGetZofVector( &m_pri_stSphereCenter ) );
	return MTH_M_xRealToDouble (MTH3D_M_xGetZofVector (&m_pri_p_stEnv->stSphereCenter));
	//ENDROMTEAM Bugs Correction (Cristian Stegaru)
}

double CPA_PartGen_Environment::m_pub_fn_dGetSphereRadius()
{
	return MTH_M_xRealToDouble( m_pri_p_stEnv->xRadius );
}


///////////////////////////////////////////////////////
// Acceleration and Range
void CPA_PartGen_Environment::m_pub_fn_vSetAcceleration( double _dAccelerX, double _dAccelerY, double _dAccelerZ )
{
	MTH3D_tdstVector stAcceleration;
	MTH3D_M_vSetVectorElements( &stAcceleration, MTH_M_xDoubleToReal(_dAccelerX), MTH_M_xDoubleToReal(_dAccelerY), MTH_M_xDoubleToReal(_dAccelerZ) );
  PRT_M_vSetAccelerationParticlesEnvironment( m_pri_p_stEnv, ( &stAcceleration ) );
	fn_vNotifySave();
}

double CPA_PartGen_Environment::m_pub_fn_dGetAccelerX()
{
	return MTH_M_xRealToDouble( MTH3D_M_xGetXofVector( &((m_pri_p_stEnv)->stAcceleration )) );
}

double CPA_PartGen_Environment::m_pub_fn_dGetAccelerY()
{
	return MTH_M_xRealToDouble( MTH3D_M_xGetYofVector( &((m_pri_p_stEnv)->stAcceleration )) );
}

double CPA_PartGen_Environment::m_pub_fn_dGetAccelerZ()
{
	return MTH_M_xRealToDouble( MTH3D_M_xGetZofVector( &((m_pri_p_stEnv)->stAcceleration) ) );
}

void CPA_PartGen_Environment::m_pub_fn_vSetRange( double _dRange )
{
	PRT_M_vSetAccelerationRangeParticlesEnvironment( m_pri_p_stEnv, MTH_M_xDoubleToReal(_dRange) );
	fn_vNotifySave();
}

double CPA_PartGen_Environment::m_pub_fn_dGetRange()
{
	return MTH_M_xRealToDouble( m_pri_p_stEnv->xAccelerationRange );
}


/////////////////////////////////////////////////////
// CallBack and function for save
void CPA_PartGen_Environment::m_s_fn_vCallBackSaveEnv
	(
		SCR_tdst_File_Description *_p_stFile,
		char *_p_szSectionName,
		void *_p_vData,
		SCR_tde_Ntfy_Action _eAction 
	)
{
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	CPA_PartGen_Environment *p_clEnv;
	char					szSectionName[ SCR_CV_ui_Cfg_MaxLenName ];
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

	ERROR_PREPARE_M
		(
			g_c_csPartGenModuleNameForErrors,
			"Saving an environment",
			"CPA_PartGen_Environment::m_s_fn_vCallBackSaveEnv",
			E_ERROR_GRAVITY_FATAL,
			"trying to save a NULL environment"
		);
	p_clEnv = (CPA_PartGen_Environment*)_p_vData;
	ERROR_ASSERT( p_clEnv != NULL );

	switch( _eAction )
	{
		case SCR_EA_Ntfy_AddSection:
		case SCR_EA_Ntfy_AddOrModifySection:
		case SCR_EA_Ntfy_AddOrRebuildSection:
		case SCR_EA_Ntfy_RebuildSection:
		case SCR_EA_Ntfy_ModifySection:
			{
				sprintf( szSectionName, "%s:%s", C_SectionPrtEnvDescription, (char *) LPCTSTR(p_clEnv->GetName()) );
				SCR_M_SvL0_SaveBeginSection( _p_stFile, szSectionName, SCR_CC_C_Cfg_EOL );
				p_clEnv->m_pri_fn_vSaveEnv( _p_stFile );
				SCR_M_SvL0_SaveEndSection( _p_stFile, SCR_CC_C_Cfg_EOL );
				p_clEnv->fn_vSectionSaved();
			}
			break;

		case SCR_EA_Ntfy_DeleteIfExists:
		case SCR_EA_Ntfy_DeleteSection:
			p_clEnv->fn_vSectionDeleted();
			break;
	}
}


void CPA_PartGen_Environment::m_pri_fn_vSaveEnv( SCR_tdst_File_Description *_p_stFile )
{
	short wIndex = m_pub_fn_wGetEnvType();
	
	SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtEnvType, SCR_CC_C_Cfg_NoChar );
	SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 1, M_MAKECHAR(g_C_a_csEnvironmentTypeName[wIndex]) );
	switch( wIndex )
	{
		case ((short)PRT_C_ulAlignedBoxEnv):
			SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtEnvMinMaxPoint, SCR_CC_C_Cfg_NoChar );
			SCR_fn_v_SvL0_SaveParameters_MP
				( 
					_p_stFile, SCR_EF_SvL0_Scanf, 7, "%.3f,%.3f,%.3f,%.3f,%.3f,%.3f",
					m_pub_fn_dGetBoxMinX(), m_pub_fn_dGetBoxMinY(), m_pub_fn_dGetBoxMinZ(),
					m_pub_fn_dGetBoxMaxX(), m_pub_fn_dGetBoxMaxY(), m_pub_fn_dGetBoxMaxZ() 
				);
			break;
		case ((short)PRT_C_ulSphereEnv):
			SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtEnvSphere, SCR_CC_C_Cfg_NoChar );
			SCR_fn_v_SvL0_SaveParameters_MP
				( 
					_p_stFile, SCR_EF_SvL0_Scanf, 5, "%.3f,%.3f,%.3f,%.3f",
					m_pub_fn_dGetSphereCenterX(), m_pub_fn_dGetSphereCenterY(), m_pub_fn_dGetSphereCenterZ(),
					m_pub_fn_dGetSphereRadius() 
				);
			break;
		}

	SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtEnvAcceleration, SCR_CC_C_Cfg_NoChar );
	SCR_fn_v_SvL0_SaveParameters_MP
		( 
			_p_stFile, SCR_EF_SvL0_Scanf, 5, "%.3f,%.3f,%.3f,%.3f",
			m_pub_fn_dGetAccelerX(), m_pub_fn_dGetAccelerY(), m_pub_fn_dGetAccelerZ(),
			m_pub_fn_dGetRange() 
		);
}


void CPA_PartGen_Environment::m_pri_fn_vFillDataList()
{
	CTL_Editor_Data *p_clData = NULL;
	CTL_Editor_EnumDescriptor *p_clEnumDescriptor = NULL;

	//**** Environment type *********************
	p_clEnumDescriptor = m_pub_fn_p_clGetDocument()->m_pub_fn_p_clGetEnumDescriptorByName( "Env_Type" );
	p_clData = m_pub_clDataList.m_fn_pclAddEnumData( p_clEnumDescriptor, "Environment Type" );
	p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stEnv->ulEnvType) );
	p_clData->m_pub_fn_vSetDataChangedSpecialCallBackFunction( g_fn_vCallBackDataChangedSpecialDisplayGenerator );
	p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedEnv" );
	p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedEnv );

	//*** Box Min env *******************************
	p_clData = m_pub_clDataList.m_fn_pclAddVectorData( sizeof(MTH_tdxReal), "Min" );
	p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_stMinPoint) );
	p_clData->m_pub_fn_pclAddOwnerData( (void*)&(m_pri_p_stEnv->ulEnvType), "EnvType" );
	p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedEnv" );
	p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedEnv );
	p_clData->m_pub_fn_vSetModificationFunctionWhenWrite( g_fn_vModificationWriteEnvBox );

	//*** Box Max env *******************************
	p_clData = m_pub_clDataList.m_fn_pclAddVectorData( sizeof(MTH_tdxReal), "Max" );
	p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_stMaxPoint) );
	p_clData->m_pub_fn_pclAddOwnerData( (void*)&(m_pri_p_stEnv->ulEnvType), "EnvType" );
	p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedEnv" );
	p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedEnv );
	p_clData->m_pub_fn_vSetModificationFunctionWhenWrite( g_fn_vModificationWriteEnvBox );

	//*** Sphere Center *****************************
	p_clData = m_pub_clDataList.m_fn_pclAddVectorData( sizeof(MTH_tdxReal), "Center" );
	//ROMTEAM Bugs Correction (Cristian Stegaru 24/03/98)
	//	p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_stSphereCenter) );
	p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stEnv->stSphereCenter) );
	//ENDROMTEAM Bugs Correction (Cristian Stegaru)
	p_clData->m_pub_fn_pclAddOwnerData( (void*)&(m_pri_p_stEnv->ulEnvType), "EnvType" );
	p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedEnv" );
	p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedEnv );
	p_clData->m_pub_fn_vSetModificationFunctionWhenWrite( g_fn_vModificationWriteEnvSphere );

	//*** Sphere radius ******************************
	p_clData = m_pub_clDataList.m_fn_pclAddDecimalData( sizeof(MTH_tdxReal), "Radius" );
	p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stEnv->xRadius) );
	p_clData->m_pub_fn_pclAddOwnerData( (void*)&(m_pri_p_stEnv->ulEnvType), "EnvType" );
	p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedEnv" );
	p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedEnv );

	//*** Acceleration ******************************
	p_clData = m_pub_clDataList.m_fn_pclAddVectorData( sizeof(MTH_tdxReal), "Acceleration" );
	p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stEnv->stAcceleration) );
	p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedEnv" );
	p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedEnv );

	//*** Acceleration range *******************************
	p_clData = m_pub_clDataList.m_fn_pclAddDecimalData( sizeof(MTH_tdxReal), "Range" );
	p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stEnv->xAccelerationRange) );
	p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedEnv" );
	p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedEnv );
}

CPA_PartGen_MyDocument * CPA_PartGen_Environment::m_pub_fn_p_clGetDocument()
{
	return g_pclInterface->m_pub_fn_p_clGetDocument();
}

