703 lines
24 KiB
C++
703 lines
24 KiB
C++
// Implementation file for the definition of a characteristic type
|
|
/////////////////////////////////////////////////////////////////////
|
|
#include "StdAfx.h"
|
|
|
|
#include "ACP_Base.h"
|
|
|
|
/////////////////////////////////////////////////////
|
|
//////// !!!!!!!!!!!! DANGER !!!!!!!!!!! ////////////
|
|
/////////////////////////////////////////////////////
|
|
#define _ED_CAR_MUST_DEFINE_STRUCT_
|
|
#include "EdAllAct.hpp"
|
|
/////////////////////////////////////////////////////
|
|
//////// !!!!!!!!!!!! End DANGER !!!!!!!!!!! ////////
|
|
/////////////////////////////////////////////////////
|
|
|
|
#include "_AInterf.hpp"
|
|
|
|
#include "CPA_DatO.hpp"
|
|
|
|
#include "EDACactr.hpp"
|
|
#include "edtlist.hpp"
|
|
#include "EDACStrg.hpp"
|
|
|
|
//External Modules
|
|
#include "ITF.h"
|
|
#include "TAC.h"
|
|
#include "ErO.h"
|
|
//End of External Modules
|
|
|
|
#undef CPA_WANTS_IMPORT
|
|
#undef CPA_EXPORT
|
|
#define CPA_WANTS_EXPORT
|
|
#include "_Actors.hpp"
|
|
#undef CPA_WANTS_EXPORT
|
|
#define CPA_WANTS_IMPORT
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
|
|
//Constructors / Destructor
|
|
//**************************************************************************************
|
|
CPA_Editor_ObjectListData::CPA_Editor_ObjectListData(CString csScriptName,
|
|
CTL_Editor_DataList *_pclParentList,
|
|
CTL_Editor_Data *pclCurrentBaseData /*= NULL*/)
|
|
: CTL_Editor_Data(CTL_DATA_TYPE__USE_USER_DEFINED_TYPE,
|
|
csScriptName,
|
|
_pclParentList,
|
|
pclCurrentBaseData,
|
|
OAC_DATA_TYPE__OBJECT_LIST)
|
|
{
|
|
m_p_oObjectList = NULL;
|
|
m_p_oNameList = NULL;
|
|
m_p_oZAList = NULL;
|
|
}
|
|
|
|
//**************************************************************************************
|
|
CPA_Editor_ObjectListData::~CPA_Editor_ObjectListData()
|
|
{
|
|
|
|
}
|
|
|
|
//**************************************************************************************
|
|
void CPA_Editor_ObjectListData::m_vSetZAList(CPA_ZonesActivatingList *_p_oZAList)
|
|
{
|
|
if ( m_p_oZAList != _p_oZAList )
|
|
{
|
|
//tell the coherence manager to remember the actor no longer uses its old activation list.
|
|
if ( m_p_oZAList )
|
|
g_oCoherenceManager.m_fn_vRemoveALink(
|
|
(CPA_SaveObject *) OAC_fn_pclGetParentActorOfData(this)->m_pclActor,
|
|
m_p_oZAList
|
|
);
|
|
//tell the coherence manager to remember the instance now uses the new activation list.
|
|
if ( _p_oZAList )
|
|
g_oCoherenceManager.m_fn_vAddALink(
|
|
(CPA_SaveObject *) OAC_fn_pclGetParentActorOfData(this)->m_pclActor,
|
|
_p_oZAList
|
|
);
|
|
//now we can set the new value
|
|
m_p_oZAList = _p_oZAList;
|
|
|
|
if ( !g_pclInterface->GetInterface()->fn_bIsLoadingWorld() )
|
|
OAC_fn_pclGetParentActorOfData(this)->m_pclActor->fn_vNotifySave();
|
|
}
|
|
}
|
|
|
|
//**************************************************************************************
|
|
void CPA_Editor_ObjectListData::m_vSetObjectList(EdtList *_p_oObjectList)
|
|
{
|
|
if ( m_p_oObjectList != _p_oObjectList )
|
|
{
|
|
if ( m_p_oObjectList )
|
|
m_p_oObjectList->fn_bMakeActorNotUseThisList(OAC_fn_pclGetParentActorOfData(this) , FALSE); // No NotifySave
|
|
if ( _p_oObjectList )
|
|
_p_oObjectList->fn_bMakeActorUseThisList(OAC_fn_pclGetParentActorOfData(this) , FALSE); // No NotifySave
|
|
//now we can set the new value
|
|
m_p_oObjectList = _p_oObjectList; //should be useless...
|
|
}
|
|
}
|
|
|
|
//**************************************************************************************
|
|
//Function called to Init the data
|
|
void CPA_Editor_ObjectListData::m_vUpdateEngineZAList()
|
|
{
|
|
MS_tdxHandleToCollSet hCollSet = (MS_tdxHandleToCollSet) OAC_fn_pclGetParentAMSOfData(this)->m_fn_pvGetBaseAddress();
|
|
ZDX_tdxHandleToCsaList hActivationList;
|
|
|
|
// get engine activation list
|
|
if ( m_p_oZAList )
|
|
hActivationList = (ZDX_tdxHandleToCsaList) m_p_oZAList->GetData();
|
|
else
|
|
hActivationList = NULL;
|
|
|
|
//set activation list
|
|
if ( m_pub_fn_csGetDataName() == C_szZdeName )
|
|
CS_M_SetActivationList(Zde, hCollSet, hActivationList);
|
|
else if ( m_pub_fn_csGetDataName() == C_szZddName )
|
|
CS_M_SetActivationList(Zdd, hCollSet, hActivationList);
|
|
else if ( m_pub_fn_csGetDataName() == C_szZdmName )
|
|
CS_M_SetActivationList(Zdm, hCollSet, hActivationList);
|
|
else if ( m_pub_fn_csGetDataName() == C_szZdrName )
|
|
CS_M_SetActivationList(Zdr, hCollSet, hActivationList);
|
|
}
|
|
|
|
//**************************************************************************************
|
|
//Function called to Init the data
|
|
void CPA_Editor_ObjectListData::m_vUpdateEngineObjectList()
|
|
{
|
|
MS_tdxHandleToCollSet hCollSet = (MS_tdxHandleToCollSet) OAC_fn_pclGetParentAMSOfData(this)->m_fn_pvGetBaseAddress();
|
|
ZDX_tdxHandleToZdxList hZdxList;
|
|
|
|
// get engine object list
|
|
if ( m_p_oObjectList )
|
|
hZdxList = (ZDX_tdxHandleToZdxList) m_p_oObjectList->fn_hGetMotorList();
|
|
else
|
|
hZdxList = NULL;
|
|
|
|
// set object list
|
|
if ( m_pub_fn_csGetDataName() == C_szZdeName )
|
|
CS_M_SetZdxList(Zde, hCollSet, hZdxList);
|
|
else if ( m_pub_fn_csGetDataName() == C_szZddName )
|
|
CS_M_SetZdxList(Zdd, hCollSet, hZdxList);
|
|
else if ( m_pub_fn_csGetDataName() == C_szZdmName )
|
|
CS_M_SetZdxList(Zdm, hCollSet, hZdxList);
|
|
else if ( m_pub_fn_csGetDataName() == C_szZdrName )
|
|
CS_M_SetZdxList(Zdr, hCollSet, hZdxList);
|
|
}
|
|
|
|
//**************************************************************************************
|
|
//Function called to Init the data
|
|
void CPA_Editor_ObjectListData::m_fn_vInitData()
|
|
{
|
|
if ( OAC_fn_bBelongsToAnInstance(this) )
|
|
{
|
|
// The instance must have the same list of names (Zdd/Zde/Zdm/Way) as the model
|
|
EdActors_EditorActor *p_oEditorModel = OAC_fn_pclGetParentActorOfData(this)->m_pclActor->m_fn_pclGetModel()->m_fn_pclGetEditorActor();
|
|
m_p_oNameList = ((CPA_Editor_ObjectListData *) p_oEditorModel->m_fn_p_oFindDataByName(m_pub_fn_csGetDataName()))->m_p_oNameList;
|
|
//make it also update en editor list pointers according to the engine handles
|
|
m_fn_vGetMotorData();
|
|
}
|
|
}
|
|
|
|
//**************************************************************************************
|
|
//Function called to read associated motor's data
|
|
void CPA_Editor_ObjectListData::m_fn_vGetMotorData()
|
|
{
|
|
//get the handle to the engine list
|
|
ZDX_tdxHandleToZdxList hZdxList = * (ZDX_tdxHandleToZdxList *) m_pro_pvMotorData;
|
|
//the IA can change the activation lists and zone lists of an object -> read them and store them
|
|
//in the editor data
|
|
|
|
//find the reachable object for the engine list
|
|
if ( hZdxList )
|
|
{
|
|
CPA_BaseObject *p_oZDxEdtList = g_pclInterface->GetMainWorld()->fn_p_oFindObjectWithEngine(
|
|
hZdxList,
|
|
C_szEdtListTypeName
|
|
);
|
|
//make the actor reference the found object list
|
|
m_vSetObjectList((EdtList *)p_oZDxEdtList);
|
|
}
|
|
|
|
//do it too for m_p_oZAList
|
|
ZDX_tdxHandleToCsaList hActivationList;
|
|
if ( m_pub_fn_csGetDataName() == C_szZdeName )
|
|
hActivationList = ((MS_tdxHandleToCollSet) OAC_fn_pclGetParentAMSOfData(this)->m_fn_pvGetBaseAddress())->hZdeActivationList;
|
|
else if ( m_pub_fn_csGetDataName() == C_szZddName )
|
|
hActivationList = ((MS_tdxHandleToCollSet) OAC_fn_pclGetParentAMSOfData(this)->m_fn_pvGetBaseAddress())->hZddActivationList;
|
|
else if ( m_pub_fn_csGetDataName() == C_szZdmName )
|
|
hActivationList = ((MS_tdxHandleToCollSet) OAC_fn_pclGetParentAMSOfData(this)->m_fn_pvGetBaseAddress())->hZdmActivationList;
|
|
else if ( m_pub_fn_csGetDataName() == C_szZdrName )
|
|
hActivationList = ((MS_tdxHandleToCollSet) OAC_fn_pclGetParentAMSOfData(this)->m_fn_pvGetBaseAddress())->hZdrActivationList;
|
|
else if ( m_pub_fn_csGetDataName() == C_szWayName )
|
|
hActivationList = NULL;
|
|
else
|
|
{
|
|
ERROR_PREPARE_M(g_c_csActorModuleNameForErrors,
|
|
"Setting editor list pointers from engine handles",
|
|
"CPA_Editor_ObjectListData::m_fn_vGetMotorData()",
|
|
E_ERROR_GRAVITY_FATAL,
|
|
"No editor activation list was found for the engine activation list handle"
|
|
);
|
|
ERROR_ASSERT(FALSE);
|
|
}
|
|
//find the reachable object for the engine list
|
|
if ( hActivationList )
|
|
{
|
|
CPA_ZonesActivatingList *p_oNewZAList = (CPA_ZonesActivatingList *) g_pclInterface->GetMainWorld()->fn_p_oFindObjectWithEngine(
|
|
hActivationList,
|
|
C_szZAListTypeName
|
|
);
|
|
m_vSetZAList(p_oNewZAList);
|
|
}
|
|
}
|
|
|
|
//**************************************************************************************
|
|
//Function called to update associated motor's data from editor data
|
|
void CPA_Editor_ObjectListData::m_fn_vUpdateMotorData(CTL_tdeUpdateReason eReason,
|
|
long _lUserDefinedReason /*= 0*/)
|
|
{
|
|
MS_tdxHandleToCollSet hCollSet = (MS_tdxHandleToCollSet) OAC_fn_pclGetParentAMSOfData(this)->m_fn_pvGetBaseAddress();
|
|
MS_tdxHandleToMSWay hWay = (MS_tdxHandleToMSWay) OAC_fn_pclGetParentAMSOfData(this)->m_fn_pvGetBaseAddress();
|
|
ZDX_tdxHandleToZdxList hZdxList;
|
|
|
|
ZDX_tdxHandleToCsaList hActivationList;
|
|
|
|
if ( m_p_oObjectList )
|
|
{
|
|
hZdxList = (ZDX_tdxHandleToZdxList) m_p_oObjectList->fn_hGetMotorList();
|
|
}
|
|
else
|
|
hZdxList = NULL;
|
|
|
|
if ( m_p_oZAList )
|
|
hActivationList = (ZDX_tdxHandleToCsaList) m_p_oZAList->GetData();
|
|
else
|
|
hActivationList = NULL;
|
|
|
|
//set the object and activation list
|
|
if ( m_pub_fn_csGetDataName() == C_szZdeName )
|
|
{
|
|
CS_M_SetZdxList(Zde, hCollSet, hZdxList);
|
|
CS_M_SetActivationList(Zde, hCollSet, hActivationList);
|
|
}
|
|
else if ( m_pub_fn_csGetDataName() == C_szZddName )
|
|
{
|
|
CS_M_SetZdxList(Zdd, hCollSet, hZdxList);
|
|
CS_M_SetActivationList(Zdd, hCollSet, hActivationList);
|
|
}
|
|
else if ( m_pub_fn_csGetDataName() == C_szZdmName )
|
|
{
|
|
CS_M_SetZdxList(Zdm, hCollSet, hZdxList);
|
|
CS_M_SetActivationList(Zdm, hCollSet, hActivationList);
|
|
}
|
|
else if ( m_pub_fn_csGetDataName() == C_szZdrName )
|
|
{
|
|
CS_M_SetZdxList(Zdr, hCollSet, hZdxList);
|
|
CS_M_SetActivationList(Zdr, hCollSet, hActivationList);
|
|
}
|
|
//Special changes
|
|
m_fn_vDataHasBeenChanged(eReason, _lUserDefinedReason);
|
|
}
|
|
|
|
//************************************************************************
|
|
//Function called to update data with another one
|
|
void CPA_Editor_ObjectListData::m_fn_vUpdateData(CTL_Editor_Data *pclSourceData,
|
|
CTL_tdeUpdateReason eReason,
|
|
long _lUserDefinedReason /*= 0*/)
|
|
{
|
|
ERROR_PREPARE_M(g_c_csActorModuleNameForErrors,
|
|
"Copying data from a model into an instance",
|
|
"CPA_Editor_ObjectListData::m_fn_vUpdateData(...)",
|
|
E_ERROR_GRAVITY_FATAL,
|
|
"The data types are not equal"
|
|
);
|
|
ERROR_ASSERT( pclSourceData->m_pub_fn_tdeGetDataType() == m_pub_fn_tdeGetDataType() );
|
|
|
|
BOOL bChanged = FALSE;
|
|
|
|
switch (eReason)
|
|
{
|
|
case E_ur_InstanciatedFromModel:
|
|
case E_ur_ModelChangedNameList:
|
|
// do something only if the model has a valid name list
|
|
if ( ((CPA_Editor_ObjectListData *) pclSourceData)->m_p_oNameList )
|
|
{
|
|
//set the instance with the values of the model
|
|
m_p_oNameList = ((CPA_Editor_ObjectListData *) pclSourceData)->m_p_oNameList;
|
|
// if the model has no default object list yet, create one.
|
|
//if ( !((CPA_Editor_ObjectListData *) pclSourceData)->m_p_oObjectList )
|
|
//{
|
|
tdstEdtListMess stMessage;
|
|
stMessage.csListType = LPCTSTR(pclSourceData->m_pub_fn_csGetDataName());
|
|
stMessage.pActor = (CPA_SaveObject *) OAC_fn_pclGetParentActorOfData(this)->m_pclActor;
|
|
//create an object list for the model
|
|
((CPA_Editor_ObjectListData *) pclSourceData)->m_p_oNameList
|
|
->m_pEdtListHandler->fn_poCreateEdtList(&stMessage);
|
|
|
|
//m_p_oObjectList = ((CPA_Editor_ObjectListData *) pclSourceData)->m_p_oObjectList;
|
|
|
|
bChanged = TRUE;
|
|
|
|
/*m_fn_bSetLink(pclSourceData->m_fn_eGetLink());
|
|
|
|
m_fn_vUpdateMotorData();*/
|
|
}
|
|
if ( ((CPA_Editor_ObjectListData *) pclSourceData)->m_p_oZAList )
|
|
{
|
|
if ( ((CPA_tdoNameList *) ((CPA_Editor_ObjectListData *) pclSourceData)->m_p_oZAList->GetOwner()) != m_p_oNameList )
|
|
((CPA_Editor_ObjectListData *) pclSourceData)->m_vSetZAList(NULL);
|
|
else
|
|
m_vSetZAList(((CPA_Editor_ObjectListData *) pclSourceData)->m_p_oZAList);
|
|
|
|
bChanged = TRUE;
|
|
}
|
|
|
|
if ( bChanged )
|
|
{
|
|
// m_fn_bSetLink(pclSourceData->m_fn_eGetLink());
|
|
m_fn_vUpdateMotorData(eReason, _lUserDefinedReason);
|
|
}
|
|
break;
|
|
|
|
case E_ur_ModelEditedNameList:
|
|
//if the model just modified the contents of some name lists, we dont care.
|
|
break;
|
|
|
|
default:
|
|
ERROR_PREPARE_M(g_c_csActorModuleNameForErrors,
|
|
"Copying data from a model into an instance",
|
|
"CPA_Editor_ObjectListData::m_fn_vUpdateData(...)",
|
|
E_ERROR_GRAVITY_FATAL,
|
|
"No good valid reason was given for data update (i.e. model changed some data)"
|
|
);
|
|
ERROR_ASSERT(FALSE);
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
//************************************************************************
|
|
//Function called to get a string representing the value of the data
|
|
CStringList *CPA_Editor_ObjectListData::m_fn_pcslFormatDataValueString()
|
|
{
|
|
m_csStringList.RemoveAll();
|
|
|
|
m_csStringList.AddTail(m_p_oNameList ? m_p_oNameList->GetName() : "");
|
|
|
|
BOOL bSaveOL, bSaveZAL;
|
|
|
|
//save the ZA list only for zones, and if we have one...
|
|
bSaveZAL = ((m_p_oZAList && (m_pub_fn_csGetDataName() != C_szWayName)) ? TRUE : FALSE);
|
|
|
|
if ( OAC_fn_bBelongsToAnInstance(this) ) //if an instance
|
|
{
|
|
//save the object list if we have one
|
|
bSaveOL = (m_p_oObjectList ? TRUE : FALSE);
|
|
}
|
|
else //is a model
|
|
{
|
|
//a model does not save its ways object list, and zone object lists
|
|
//are saved only if they have no virge field
|
|
bSaveOL = (m_p_oObjectList && (m_pub_fn_csGetDataName() != C_szWayName) && m_p_oNameList->m_bHasACommonField());
|
|
}
|
|
|
|
m_csStringList.AddTail(bSaveOL ? m_p_oObjectList->GetName() : "");
|
|
m_csStringList.AddTail(bSaveZAL ? m_p_oZAList->GetName() : "");
|
|
return &m_csStringList;
|
|
}
|
|
|
|
//************************************************************************
|
|
//Function called to set the value of the data acoording to a string representing it
|
|
void CPA_Editor_ObjectListData::m_fn_vSetValueWithString(CStringList *pcslValueStringList)
|
|
{
|
|
ERROR_PREPARE_M(g_c_csActorModuleNameForErrors,
|
|
"Filling data with script information",
|
|
"CPA_Editor_ObjectListData::m_fn_vSetValueWithString(...)",
|
|
E_ERROR_GRAVITY_FATAL,
|
|
"The number of fields to fill and provided data do not correspond"
|
|
);
|
|
ERROR_ASSERT(pcslValueStringList->GetCount() == 3);
|
|
POSITION xPos = pcslValueStringList->GetHeadPosition();
|
|
CString csNameList(pcslValueStringList->GetNext(xPos));
|
|
CString csObjectList(pcslValueStringList->GetNext(xPos));
|
|
CString csZAList(pcslValueStringList->GetNext(xPos));
|
|
|
|
// Get the main world
|
|
CPA_MainWorld * pMainWorld = OAC_fn_pclGetParentActorOfData(this)->m_pclActor->GetMainWorld ();
|
|
|
|
// Search the name list
|
|
if ( m_p_oNameList )
|
|
g_oCoherenceManager.m_fn_vRemoveALink(
|
|
(CPA_SaveObject *) OAC_fn_pclGetParentActorOfData(this)->m_pclActor,
|
|
m_p_oNameList
|
|
);
|
|
m_p_oNameList = NULL;
|
|
if ( !csNameList.IsEmpty() )
|
|
{
|
|
CPA_BaseObject *p_oFamily = (CPA_BaseObject *) OAC_fn_pclGetParentActorOfData(this)->m_pclActor->m_pub_fn_pclGetFamily();
|
|
m_p_oNameList = (CPA_tdoNameList *) pMainWorld -> fn_p_oFindObject (csNameList, C_szZDdNameListType, p_oFamily);
|
|
if ( !m_p_oNameList )
|
|
m_p_oNameList = (CPA_tdoNameList *) pMainWorld -> fn_p_oFindObject (csNameList, C_szZDeNameListType, p_oFamily);
|
|
if ( !m_p_oNameList )
|
|
m_p_oNameList = (CPA_tdoNameList *) pMainWorld -> fn_p_oFindObject (csNameList, C_szZDmNameListType, p_oFamily);
|
|
if ( !m_p_oNameList )
|
|
m_p_oNameList = (CPA_tdoNameList *) pMainWorld -> fn_p_oFindObject (csNameList, C_szZDrNameListType, p_oFamily);
|
|
// add by jt
|
|
if ( !m_p_oNameList )
|
|
m_p_oNameList = (CPA_tdoNameList *) pMainWorld -> fn_p_oFindObject (csNameList, C_szWayNameListType, p_oFamily);
|
|
// end jt
|
|
ERROR_PREPARE_M(g_c_csActorModuleNameForErrors,
|
|
"Filling data with script information",
|
|
"CPA_Editor_ObjectListData::m_fn_vSetValueWithString(...)",
|
|
E_ERROR_GRAVITY_FATAL,
|
|
"No editor name list was found with the specified name"
|
|
);
|
|
ERROR_ASSERT(m_p_oNameList);
|
|
}
|
|
//tell the coherence manager to remember the model now uses the new name list.
|
|
if ( m_p_oNameList )
|
|
g_oCoherenceManager.m_fn_vAddALink(
|
|
OAC_fn_pclGetParentActorOfData(this)->m_pclActor,
|
|
m_p_oNameList
|
|
);
|
|
|
|
|
|
// We set the pointer of the model to the name list
|
|
if ( !csObjectList.IsEmpty() )
|
|
{
|
|
EdtList *p_oObjectList = (EdtList *) pMainWorld -> fn_p_oFindObject (csObjectList, C_szEdtListTypeName, m_p_oNameList ? m_p_oNameList : NO_CRITERIA );
|
|
ERROR_PREPARE_M(g_c_csActorModuleNameForErrors,
|
|
"Filling data with script information",
|
|
"CPA_Editor_ObjectListData::m_fn_vSetValueWithString(...)",
|
|
E_ERROR_GRAVITY_FATAL,
|
|
"No editor object list was found with the specified name"
|
|
);
|
|
ERROR_ASSERT(p_oObjectList);
|
|
m_vSetObjectList(p_oObjectList);
|
|
}
|
|
else
|
|
m_vSetObjectList(NULL);
|
|
|
|
if ( !csZAList.IsEmpty() )
|
|
{
|
|
m_vSetZAList((CPA_ZonesActivatingList *) pMainWorld -> fn_p_oFindObject (csZAList, C_szZAListTypeName));
|
|
ERROR_PREPARE_M(g_c_csActorModuleNameForErrors,
|
|
"Filling data with script information",
|
|
"CPA_Editor_ObjectListData::m_fn_vSetValueWithString(...)",
|
|
E_ERROR_GRAVITY_FATAL,
|
|
"No editor activation list was found with the specified name"
|
|
);
|
|
ERROR_ASSERT(m_p_oZAList);
|
|
}
|
|
else
|
|
m_vSetZAList(NULL);
|
|
}
|
|
|
|
//************************************************************************
|
|
//Function called to look if data has been modified (by motor for example)
|
|
void CPA_Editor_ObjectListData::m_fn_vLookIfDataHasBeenModified()
|
|
{
|
|
BOOL bIsEditingAnInstance = OAC_fn_bBelongsToAnInstance(this);
|
|
|
|
m_fn_vGetMotorData();
|
|
|
|
m_pro_bDataHasChanged = bIsEditingAnInstance
|
|
? ((m_p_oObjectList != m_p_oOldObjectList) || (m_p_oZAList != m_p_oOldZAList ))
|
|
: (m_p_oNameList != m_p_oOldNameList);
|
|
|
|
if ( m_pro_bDataHasChanged )
|
|
{
|
|
if ( bIsEditingAnInstance )
|
|
{
|
|
m_p_oOldObjectList = m_p_oObjectList;
|
|
m_p_oOldZAList = m_p_oZAList;
|
|
}
|
|
else
|
|
m_p_oOldNameList = m_p_oNameList;
|
|
}
|
|
}
|
|
|
|
//************************************************************************
|
|
//Function called when data has been really modified (i.e. value is different from previous one)
|
|
void CPA_Editor_ObjectListData::m_fn_vDataHasBeenReallyModified()
|
|
{
|
|
|
|
}
|
|
|
|
//Undo
|
|
//************************************************************************
|
|
//Function called to save the current Value (for Undo)
|
|
void CPA_Editor_ObjectListData::m_fn_vKeepCurrentValue()
|
|
{
|
|
m_p_oNameListKeptForUndo = m_p_oNameList;
|
|
m_p_oObjectListKeptForUndo = m_p_oObjectList;
|
|
m_p_oZAListKeptForUndo = m_p_oZAList;
|
|
}
|
|
|
|
//************************************************************************
|
|
//Function called to validate Undo for the current change
|
|
void CPA_Editor_ObjectListData::m_fn_vRegisterUndoAction()
|
|
{
|
|
void *pKeptList, *pCurList;
|
|
void *pKeptAlternateList, *pCurAlternateList;
|
|
if ( OAC_fn_bBelongsToAnInstance(this) )
|
|
{
|
|
pKeptList = m_p_oObjectListKeptForUndo;
|
|
pCurList = m_p_oObjectList;
|
|
pKeptAlternateList = m_p_oZAListKeptForUndo;
|
|
pCurAlternateList = m_p_oZAList;
|
|
}
|
|
else
|
|
{
|
|
pKeptList = m_p_oNameListKeptForUndo;
|
|
pCurList = m_p_oNameList;
|
|
pKeptAlternateList = NULL;
|
|
pCurAlternateList = NULL;
|
|
}
|
|
|
|
CPA_ObjectListDataModif *pclModif = new CPA_ObjectListDataModif(this,
|
|
pKeptList,
|
|
pCurList,
|
|
pKeptAlternateList,
|
|
pCurAlternateList);
|
|
|
|
OAC_fn_pclGetParentActorOfData(this)->m_clUndoManager.AskFor(pclModif);
|
|
}
|
|
|
|
|
|
//##################################################################"
|
|
//************************************************************************
|
|
//Constructor
|
|
CPA_ObjectListDataModif::CPA_ObjectListDataModif
|
|
(
|
|
CPA_Editor_ObjectListData *p_oData,
|
|
void *pOldList,
|
|
void *pNewList,
|
|
void *_pOldAlternateList,
|
|
void *_pNewAlternateList
|
|
)
|
|
: CPA_Modif(0)
|
|
{
|
|
m_p_oData = p_oData;
|
|
m_pListAfterDo = pNewList;
|
|
m_pListBeforeDo = pOldList;
|
|
m_pAlternateListAfterDo = _pNewAlternateList;
|
|
m_pAlternateListBeforeDo = _pOldAlternateList;
|
|
|
|
CString csName;
|
|
csName.Format("%s : modified", p_oData->m_pub_fn_csGetDataName());
|
|
SetName(csName);
|
|
}
|
|
|
|
//************************************************************************
|
|
//Destructor
|
|
CPA_ObjectListDataModif::~CPA_ObjectListDataModif()
|
|
{
|
|
|
|
}
|
|
|
|
//************************************************************************
|
|
BOOL CPA_ObjectListDataModif::Do()
|
|
{
|
|
if ( OAC_fn_bBelongsToAnInstance(m_p_oData) )
|
|
{
|
|
m_p_oData->m_vSetObjectList((EdtList *) m_pListAfterDo);
|
|
m_p_oData->m_vSetZAList((CPA_ZonesActivatingList *) m_pAlternateListAfterDo);
|
|
}
|
|
else
|
|
{
|
|
//remove the link with the old name list
|
|
if ( m_p_oData->m_p_oNameList )
|
|
g_oCoherenceManager.m_fn_vRemoveALink(
|
|
(CPA_SaveObject *) OAC_fn_pclGetParentActorOfData(m_p_oData)->m_pclActor,
|
|
m_p_oData->m_p_oNameList
|
|
);
|
|
//set the name name list
|
|
m_p_oData->m_p_oNameList = (CPA_tdoNameList *) m_pListAfterDo;
|
|
//and set the link with the new name list
|
|
if ( m_p_oData->m_p_oNameList )
|
|
g_oCoherenceManager.m_fn_vAddALink(
|
|
(CPA_SaveObject *) OAC_fn_pclGetParentActorOfData(m_p_oData)->m_pclActor,
|
|
m_p_oData->m_p_oNameList
|
|
);
|
|
m_p_oData->m_vSetZAList((CPA_ZonesActivatingList *) m_pAlternateListAfterDo);
|
|
}
|
|
|
|
m_p_oData->m_fn_vUpdateMotorData();
|
|
m_p_oData->m_pub_fn_vSetDataHasChanged(TRUE);
|
|
m_p_oData->m_pub_fn_pclGetParentControl()->m_fn_vUpdate();
|
|
|
|
OAC_fn_pclGetParentActorOfData(m_p_oData)->m_pclActor->fn_vNotifySave();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
//************************************************************************
|
|
BOOL CPA_ObjectListDataModif::Undo()
|
|
{
|
|
if ( OAC_fn_bBelongsToAnInstance(m_p_oData) )
|
|
{
|
|
m_p_oData->m_vSetObjectList((EdtList *) m_pListBeforeDo);
|
|
m_p_oData->m_vSetZAList((CPA_ZonesActivatingList *) m_pAlternateListBeforeDo);
|
|
}
|
|
else
|
|
{
|
|
//remove the link with the old name list
|
|
if ( m_p_oData->m_p_oNameList )
|
|
g_oCoherenceManager.m_fn_vRemoveALink(
|
|
(CPA_SaveObject *) OAC_fn_pclGetParentActorOfData(m_p_oData)->m_pclActor,
|
|
m_p_oData->m_p_oNameList
|
|
);
|
|
m_p_oData->m_p_oNameList = (CPA_tdoNameList *) m_pListBeforeDo;
|
|
//and set the link with the new name list
|
|
if ( m_p_oData->m_p_oNameList )
|
|
g_oCoherenceManager.m_fn_vAddALink(
|
|
(CPA_SaveObject *) OAC_fn_pclGetParentActorOfData(m_p_oData)->m_pclActor,
|
|
m_p_oData->m_p_oNameList
|
|
);
|
|
m_p_oData->m_vSetZAList((CPA_ZonesActivatingList *) m_pAlternateListAfterDo);
|
|
}
|
|
|
|
m_p_oData->m_fn_vUpdateMotorData();
|
|
m_p_oData->m_pub_fn_vSetDataHasChanged(TRUE);
|
|
m_p_oData->m_pub_fn_pclGetParentControl()->m_fn_vUpdate();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
// ROMTEAM corrections (Nicu 06-02-98) {
|
|
|
|
//Function called to read associated motor's data
|
|
void OAC_FloatData::m_fn_vGetMotorData()
|
|
{
|
|
BOOL bMustReadData = TRUE;
|
|
if ( m_pro_td_p_fn_bDataMustBeRead != NULL )
|
|
bMustReadData &= m_pro_td_p_fn_bDataMustBeRead(this);
|
|
|
|
if ( bMustReadData )
|
|
{
|
|
m_ldCurrentValue = *(long*)m_pro_pvMotorData / 65536.0;
|
|
|
|
//Calls Modification function if needed
|
|
if ( m_pro_td_p_fn_vDataModifWhenRead != NULL )
|
|
m_pro_td_p_fn_vDataModifWhenRead(this);
|
|
}
|
|
}
|
|
|
|
//Function called to update associated motor's data
|
|
void OAC_FloatData::m_fn_vUpdateMotorData(CTL_tdeUpdateReason eReason, long _lUserDefinedReason)
|
|
{
|
|
BOOL bMustWriteData = TRUE;
|
|
if ( m_pro_td_p_fn_bDataMustBeWritten != NULL )
|
|
bMustWriteData &= m_pro_td_p_fn_bDataMustBeWritten(this);
|
|
|
|
if ( bMustWriteData )
|
|
{
|
|
//Calls Modification function if needed
|
|
if ( m_pro_td_p_fn_vDataModifWhenWrite != NULL )
|
|
m_pro_td_p_fn_vDataModifWhenWrite(this);
|
|
|
|
*(long*)m_pro_pvMotorData = (long)(m_ldCurrentValue * 65536.0 + 0.5);
|
|
|
|
//Calls Modification function if needed
|
|
if ( m_pro_td_p_fn_vDataModifWhenRead != NULL )
|
|
m_pro_td_p_fn_vDataModifWhenRead(this);
|
|
|
|
//Special changes
|
|
m_fn_vDataHasBeenChanged(eReason, _lUserDefinedReason);
|
|
}
|
|
}
|
|
|
|
|
|
//Function called to get a string representing the value of the data
|
|
CStringList *OAC_FloatData::m_fn_pcslFormatDataValueString()
|
|
{
|
|
m_csStringList.RemoveAll();
|
|
|
|
CString csStringToReturn;
|
|
csStringToReturn.Format("%ld", (long)(m_ldCurrentValue * 65536.0 + 0.5));
|
|
m_csStringList.AddTail(csStringToReturn);
|
|
|
|
return &m_csStringList;
|
|
}
|
|
|
|
|
|
//Function called to set the value of the data acoording to a string representing it
|
|
void OAC_FloatData::m_fn_vSetValueWithString(CStringList *pcslValueStringList)
|
|
{
|
|
ERROR_ASSERT(pcslValueStringList->GetCount() == 1);
|
|
CString csValueString = pcslValueStringList->GetHead();
|
|
|
|
m_ldCurrentValue = atol(LPCTSTR(csValueString)) / 65536.0;
|
|
|
|
m_fn_vUpdateMotorData();
|
|
}
|
|
|
|
// END ROMTEAM corrections (Nicu) }
|