1458 lines
40 KiB
C++
1458 lines
40 KiB
C++
/*
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Description : WayObj.cpp
|
|
//
|
|
// Definition of the way editors objects
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// inherit from : CPA_Object
|
|
// CPA_EdMot<ACP_tdxHandleOfLink>
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Creation date: 21 jan 1997 Author: J Thénoz
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Modification date: Author:
|
|
//
|
|
//
|
|
//
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
*/
|
|
|
|
//ANNECY Shaitan Nettoyage (12/05/98) {
|
|
/*
|
|
#include "stdafx.h"
|
|
#include "acp_base.h"
|
|
#include "resource.h"
|
|
#include "incdpt.h"
|
|
#include "incitf.h"
|
|
#include "incgam.h"
|
|
#include "incai.h"
|
|
#include "WayObj.hpp"
|
|
#include "WPObj.hpp"
|
|
#include "LinkObj.hpp"
|
|
#include "Inter.hpp"
|
|
#include "WayMod.hpp"
|
|
#include "WayDia.hpp"
|
|
#include "oac.h"
|
|
#include "x:\cpa\main\inc\_editid.h"
|
|
|
|
// PROVISOIRE
|
|
#define C_szWayTypeName "Way"
|
|
|
|
|
|
char* pszWayAction = "Way";
|
|
|
|
DeclareTemplateStatic(WP_tdhWay);
|
|
|
|
|
|
//------ static
|
|
DiaWay* Way::ms_poDiaWay;
|
|
WayPoint* Way::m_poVirtualWP=NULL;
|
|
CPA_List<Way> Way::ms_oListOfWay;
|
|
Waypoint_Interface* Way::ms_poInterface;
|
|
tdeWayDisplay Way::ms_eWayDisplay;
|
|
Way* Way::ms_poCopyWay;
|
|
|
|
|
|
|
|
void Way::fn_vInitObject (Waypoint_Interface* poInterface)
|
|
{
|
|
CPA_EdMot<WP_tdhWay>::Init (WP_fnh_Way_Create, WP_fnv_Way_Copy, WP_fnv_Way_Destroy);
|
|
ms_poInterface = poInterface;
|
|
ms_eWayDisplay = eWayDisplayOff;
|
|
ms_poCopyWay = NULL;
|
|
}
|
|
|
|
|
|
void Way::fn_vSetDialog ( DiaWay* poDiaWay )
|
|
{
|
|
ms_poDiaWay=poDiaWay;
|
|
ms_poDiaWay->fn_vInitDialog ();
|
|
}
|
|
|
|
|
|
void Way::fn_vDisplayWayOfActor ( CPA_BaseObject* poInstance )
|
|
{
|
|
POSITION xPos;
|
|
Way* poWay;
|
|
CPA_List<Way> oListOfWay;
|
|
|
|
tdstEdtListMess stEdtListMess;
|
|
stEdtListMess.csListType = C_szWayName;
|
|
stEdtListMess.pActor = poInstance;
|
|
|
|
EdtList* pEdtList = (EdtList*) GetInterface()->GetInterface()->GetMainWorld()->GetObjectDLLWithName(C_szDLLActorName)->OnQueryAction (GetInterface(), C_uiActor_GetAnObjectList , (long)&stEdtListMess);
|
|
fn_oGetListOfWayUnderParent (&oListOfWay, pEdtList);
|
|
|
|
GetInterface()->fn_vSetRefreshWay (TRUE);
|
|
for (poWay = oListOfWay.GetHeadElement(xPos); poWay; poWay = oListOfWay.GetNextElement(xPos) )
|
|
if (!poWay->GetSuperObject()->GetParent()) GetInterface()->GetInterface()->fn_bInsertObjectInHierarchy (poWay->GetSuperObject(), GetInterface()->GetInterface()->GetSpecificInterface()->GetDynamicRoot(),FALSE,FALSE,FALSE );
|
|
GetInterface()->fn_vSetRefreshWay (FALSE);
|
|
}
|
|
|
|
void Way::fn_vRefreshWay (void)
|
|
{
|
|
POSITION xPos;
|
|
Way* poWay;
|
|
CPA_SuperObject* poSuperObject;
|
|
CPA_List<CPA_SuperObject>* pListOfWayInHierarchy;
|
|
CPA_List<Way> oListOfWayToRetreive;
|
|
|
|
// serach invisible ways in hierarchy
|
|
pListOfWayInHierarchy = GetInterface()->GetInterface()->GetObjectListByType("Way");
|
|
if (pListOfWayInHierarchy->GetCount())
|
|
{
|
|
for ( poSuperObject=pListOfWayInHierarchy->GetHeadElement (xPos); xPos; poSuperObject=pListOfWayInHierarchy->GetNextElement (xPos) )
|
|
{
|
|
if (poSuperObject)
|
|
{
|
|
poWay = (Way*)(poSuperObject->GetObject());
|
|
if (!poWay->fn_bIsWayDrawable()) oListOfWayToRetreive.AddTail (poWay);
|
|
|
|
// Retrieve waypoint in hierarchy
|
|
poWay->fn_vSetWaypointOnScreen (FALSE);
|
|
}
|
|
}
|
|
}
|
|
|
|
// and retreive them now
|
|
GetInterface()->fn_vSetRefreshWay (TRUE);
|
|
for ( poWay=oListOfWayToRetreive.GetHeadElement (xPos); xPos; poWay=oListOfWayToRetreive.GetNextElement (xPos) )
|
|
{
|
|
GetInterface()->fn_vSetModifDeleteOk (TRUE);
|
|
GetInterface()->GetInterface()->fn_bDeleteObjectInHierarchy (poWay->GetSuperObject(),FALSE,FALSE,FALSE,FALSE);
|
|
GetInterface()->fn_vSetModifDeleteOk (FALSE);
|
|
}
|
|
|
|
// Add the way that are not in hierarchy and should be
|
|
if (ms_oListOfWay.GetCount())
|
|
{
|
|
// add way from display control
|
|
for (poWay=ms_oListOfWay.GetHeadElement(xPos); poWay; poWay=ms_oListOfWay.GetNextElement(xPos) )
|
|
{
|
|
// the way is not in the hierarchy
|
|
if (!poWay->GetSuperObject()->GetParent())
|
|
{
|
|
if (!poWay->IsWayEmpty() && poWay->fn_bIsWayDrawable ())
|
|
{
|
|
GetInterface()->GetInterface()->fn_bInsertObjectInHierarchy (poWay->GetSuperObject(), GetInterface()->GetInterface()->GetSpecificInterface()->GetDynamicRoot(),FALSE,FALSE,FALSE );
|
|
poWay->fn_vComputeLocation ();
|
|
poWay->fn_vRefresh (TRUE, FALSE);
|
|
poWay->fn_vSetWaypointOnScreen (TRUE);
|
|
}
|
|
}
|
|
else poWay->fn_vSetWaypointOnScreen (TRUE);
|
|
}
|
|
|
|
// add way in current EdtList
|
|
if (GetInterface()->fn_pGetSelectedEdtList())
|
|
{
|
|
for (poWay=(Way*)(GetInterface()->fn_pGetSelectedEdtList()->GetHeadElement(xPos)); poWay; poWay=(Way*)(GetInterface()->fn_pGetSelectedEdtList()->GetNextElement(xPos)) )
|
|
{
|
|
// the way is not in the hierarchy
|
|
if (!poWay->GetSuperObject()->GetParent())
|
|
{
|
|
if (!poWay->IsWayEmpty())
|
|
{
|
|
GetInterface()->GetInterface()->fn_bInsertObjectInHierarchy (poWay->GetSuperObject(), GetInterface()->GetInterface()->GetSpecificInterface()->GetDynamicRoot(),FALSE,FALSE,FALSE );
|
|
poWay->fn_vComputeLocation ();
|
|
poWay->fn_vSetWaypointOnScreen (TRUE);
|
|
}
|
|
}
|
|
else poWay->fn_vSetWaypointOnScreen (TRUE);
|
|
}
|
|
}
|
|
}
|
|
GetInterface()->fn_vSetRefreshWay (FALSE);
|
|
GetInterface()->GetInterface()->fn_vCancelCurrentSelection (FALSE);
|
|
}
|
|
|
|
void Way::fn_vResetRecreate (void)
|
|
{
|
|
POSITION xPos;
|
|
Way* poWay;
|
|
|
|
for ( poWay=ms_oListOfWay.GetHeadElement(xPos); poWay; poWay=ms_oListOfWay.GetNextElement(xPos) )
|
|
poWay->fn_vSetRecreate (FALSE);
|
|
|
|
}
|
|
|
|
|
|
BOOL Way::fn_oGetListOfWayUnderParent (CPA_List<Way>* poList, CPA_BaseObject* poParent)
|
|
{
|
|
POSITION xPos;
|
|
Way* poWay;
|
|
|
|
poList->RemoveAll ();
|
|
|
|
for ( poWay=ms_oListOfWay.GetHeadElement (xPos); xPos; poWay=ms_oListOfWay.GetNextElement (xPos) )
|
|
if ( poWay->GetOwner() == poParent ) poList->AddTail (poWay);
|
|
return poList->GetCount()>0;
|
|
}
|
|
|
|
|
|
void Way::fn_vCallbackSave ( SCR_tdst_File_Description *_p_stFile, char *_p_szSectionName, void *_p_vData,SCR_tde_Ntfy_Action _eAction )
|
|
{
|
|
Way* poWay = (Way*)_p_vData;
|
|
|
|
if (poWay->IsWayEmpty())
|
|
{
|
|
poWay->fn_vSectionDeleted ();
|
|
return;
|
|
}
|
|
|
|
switch (_eAction)
|
|
{
|
|
case SCR_EA_Ntfy_AddSection :
|
|
SCR_fn_v_SvL1_ToEndSection (_p_stFile);
|
|
|
|
case SCR_EA_Ntfy_ModifySection :
|
|
case SCR_EA_Ntfy_RebuildSection :
|
|
{
|
|
// declaration
|
|
WP_tdhWay hWay;
|
|
long lSize;
|
|
char szSectionName [SCR_CV_ui_Cfg_MaxLenName];
|
|
char szObjectName [SCR_CV_ui_Cfg_MaxLenName];
|
|
|
|
//init
|
|
hWay = (WP_tdhWay)(poWay->GetStruct());
|
|
lSize = (long) WP_fnuc_Way_GetSizeWay ( hWay );
|
|
strcpy ( szObjectName, poWay->GetName() );
|
|
|
|
SCR_fn_v_RdL0_ComputeSectionName
|
|
(
|
|
szSectionName,
|
|
NULL,
|
|
pszWayAction,
|
|
szObjectName
|
|
);
|
|
|
|
SCR_M_SvL0_SaveBeginSection ( _p_stFile, szSectionName, SCR_CC_C_Cfg_NoChar );
|
|
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_ArrayLong, 2, 1, &lSize );
|
|
|
|
|
|
// waypoints
|
|
WayPoint* poWP;
|
|
POSITION xPos;
|
|
for ( poWP=poWay->GetListWaypoint()->GetHeadElement(xPos); poWP; poWP=poWay->GetListWaypoint()->GetNextElement(xPos) )
|
|
{
|
|
SCR_M_SvL0_SaveEntry( _p_stFile, "WP", SCR_CC_C_Cfg_NoChar );
|
|
strcpy ( szSectionName, poWP->GetReferencedSectionName() );
|
|
SCR_fn_v_SvL0_SaveParameters_MP ( _p_stFile, SCR_EF_SvL0_Normal, 1, szSectionName );
|
|
}
|
|
|
|
// links
|
|
Link* poLink;
|
|
for ( poLink=poWay->GetListLink()->GetHeadElement(xPos); poLink; poLink=poWay->GetListLink()->GetNextElement(xPos) )
|
|
poLink->fn_vSave ( _p_stFile );
|
|
|
|
SCR_M_SvL0_SaveEndSection (_p_stFile, SCR_CC_C_Cfg_EOL);
|
|
poWay->fn_vSectionSaved ();
|
|
} break;
|
|
|
|
case SCR_EA_Ntfy_DeleteSection :
|
|
poWay->fn_vSectionDeleted ();
|
|
break;
|
|
|
|
}
|
|
}
|
|
|
|
BOOL Way::fn_bCheckWayCoherence ( CPA_List<Way>* poWayList )
|
|
{
|
|
BOOL bCheckWayCoherence = TRUE;
|
|
|
|
Position xPos;
|
|
CPA_BaseObject* poBaseObject;
|
|
long lCounter=0;
|
|
CPA_ObjectDLLBase* poActorDll = GetInterface()->GetInterface()->GetMainWorld()->GetObjectDLLWithName(C_szDLLActorName);
|
|
|
|
CPA_BaseObjectList* poList = GetInterface()->GetInterface()->GetMainWorld()->fn_p_oGetOriginalObjectList (C_szEdtListTypeName);
|
|
|
|
// for each EdtList
|
|
for (poBaseObject=poList->GetHeadElement (xPos); poBaseObject; poBaseObject=poList->GetNextElement (xPos) )
|
|
{
|
|
EdtList* poEdtList = (EdtList*) poBaseObject;
|
|
|
|
|
|
// select only Way EdtList
|
|
if (poEdtList->fn_csGetListType()==C_szWayName)
|
|
{
|
|
|
|
CPA_BaseObject* poActor = GetInterface()->fn_pGetActorUsingAList (poEdtList);
|
|
if (poActor)
|
|
{
|
|
if (poActor->fn_bIsValid() && poActorDll->OnQueryAction (GetInterface(), C_uiActor_IsAnInstance , (long)poActor))
|
|
{
|
|
|
|
|
|
// find Namelist
|
|
CPA_tdoNameList* poNameList = poEdtList->fn_oGetNameList();
|
|
|
|
POSITION xNamePos, xWayPos;
|
|
tdoObjectName* poName;
|
|
CPA_SaveObject* poWay;
|
|
|
|
// for each name in the list
|
|
for
|
|
(
|
|
poName=poNameList->GetHeadElement(xNamePos),
|
|
poWay=poEdtList->GetHeadElement(xWayPos);
|
|
poName;
|
|
poName=poNameList->GetNextElement(xNamePos),
|
|
poWay=poEdtList->GetNextElement(xWayPos)
|
|
)
|
|
{
|
|
// Is this name use in AI script ?
|
|
CList<CPA_BaseObject*,CPA_BaseObject*> oFatherList;
|
|
int iFatherNb = g_oCoherenceManager.m_fn_iGetFatherList ( poName, &oFatherList );
|
|
|
|
if (iFatherNb)
|
|
{
|
|
POSITION xPos;
|
|
CPA_BaseObject* poBaseObject;
|
|
BOOL bNameReferenced=FALSE;
|
|
|
|
for ( xPos=oFatherList.GetHeadPosition(); xPos && !bNameReferenced; oFatherList.GetNext(xPos) )
|
|
{
|
|
poBaseObject = oFatherList.GetAt (xPos);
|
|
if (poBaseObject->GetType()==C_szIABehaviourTypeName) bNameReferenced=TRUE;
|
|
}
|
|
|
|
if (bNameReferenced)
|
|
{
|
|
// the way is Ok ?
|
|
BOOL bWayIsInvalid=FALSE;
|
|
if (!poWay) bWayIsInvalid=TRUE;
|
|
else if (((Way*)poWay)->IsWayEmpty()) bWayIsInvalid=TRUE;
|
|
|
|
// No, Bad way
|
|
if (bWayIsInvalid)
|
|
{
|
|
bCheckWayCoherence=FALSE;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
return bCheckWayCoherence;
|
|
}
|
|
|
|
|
|
// to create a new instance
|
|
Way::Way( CPA_ObjectDLLBase *p_oDLL, CPA_BaseObject* poFamilly ):
|
|
CPA_SaveObject ( p_oDLL, C_szWayTypeName, E_ss_Responsible, poFamilly ),
|
|
CPA_EdMot<WP_tdhWay>()
|
|
{
|
|
char szSectionName [SCR_CV_ui_Cfg_MaxLenName];
|
|
char szFamillyName [SCR_CV_ui_Cfg_MaxLenName];
|
|
char szTmp [SCR_CV_ui_Cfg_MaxLenName];
|
|
|
|
m_WaypointList.RemoveAll ();
|
|
m_LinkList.RemoveAll ();
|
|
m_lMode = c_Way_Normal;
|
|
m_lWPInsertBefore = 0;
|
|
m_cDefaultLink=WP_ConnType_ucStaticLine;
|
|
m_pOldLink=NULL;
|
|
m_bRecreate=FALSE;
|
|
m_bRotationMode=FALSE;
|
|
m_eWayDisplay=eWayDisplayOff;
|
|
|
|
|
|
// registre in the list
|
|
ms_oListOfWay.AddTail (this);
|
|
|
|
char szLevelFileName [256];
|
|
fn_zsGetActualLevelFilename (szLevelFileName,"way");
|
|
long lSizePath = strlen ( fn_szGetLevelsDataPath() );
|
|
CString csLevelName = szLevelFileName+lSizePath+1;
|
|
|
|
fn_zsGetActualLevelFilename (szTmp , "");
|
|
char * p_cSlash = strrchr (szTmp , '\\') + 1 ;
|
|
char * p_cPoint = strrchr (szTmp , '.');
|
|
* p_cPoint = 0;
|
|
sprintf (szFamillyName , "%s\\Families\\%s\\%s.way" , p_cSlash , poFamilly->fn_p_szGetName (), poFamilly->fn_p_szGetName () );
|
|
|
|
// section object
|
|
SetSectionData ( this ) ;
|
|
SetCallBackSave ( fn_vCallbackSave ) ;
|
|
SetDataPath ( fn_szGetLevelsDataPath() ) ;
|
|
SCR_fn_v_RdL0_ComputeSectionName ( szSectionName, szFamillyName, pszWayAction, " ");
|
|
SetReferencedSectionName (szSectionName);
|
|
|
|
// name
|
|
if ( fn_eRename ("Way1") != E_mc_None)
|
|
SetDefaultValidName ( ) ;
|
|
|
|
fn_vUpdateSectionName ( ) ;
|
|
|
|
SetExistingSection (FALSE) ;
|
|
}
|
|
|
|
|
|
// to load a way
|
|
Way::Way( CPA_ObjectDLLBase *p_oDLL, WP_tdhWay hWayEngine, CPA_BaseObject* poOwner, CString csName, CString csReferencedSectionName ) :
|
|
CPA_SaveObject ( p_oDLL, C_szWayTypeName, E_ss_Responsible, poOwner ),
|
|
CPA_EdMot<WP_tdhWay>(hWayEngine)
|
|
{
|
|
char szSectionName [SCR_CV_ui_Cfg_MaxLenName];
|
|
|
|
m_WaypointList.RemoveAll ();
|
|
m_LinkList.RemoveAll ();
|
|
m_lMode = c_Way_Normal;
|
|
m_lWPInsertBefore = 0;
|
|
m_xLBeam = 0.05f;
|
|
m_cDefaultLink=WP_ConnType_ucStaticLine;
|
|
m_pOldLink=NULL;
|
|
m_bRecreate=FALSE;
|
|
m_bRotationMode=FALSE;
|
|
m_eWayDisplay=eWayDisplayOff;
|
|
|
|
// registre in the list
|
|
ms_oListOfWay.AddTail (this);
|
|
|
|
// section object
|
|
SetSectionData ( this ) ;
|
|
SetCallBackSave ( fn_vCallbackSave ) ;
|
|
SetDataPath ( fn_szGetLevelsDataPath() ) ;
|
|
SCR_fn_v_RdL0_ComputeSectionName ( szSectionName, (char *)(LPCSTR)csReferencedSectionName, pszWayAction, " ");
|
|
SetReferencedSectionName (szSectionName);
|
|
|
|
// name
|
|
if ( fn_eRename (csName) != E_mc_None)
|
|
SetDefaultValidName ( ) ;
|
|
|
|
fn_vUpdateSectionName ( ) ;
|
|
|
|
SetExistingSection (TRUE) ;
|
|
|
|
|
|
}
|
|
|
|
|
|
Way::Way ( Way& rWay ) :
|
|
CPA_SaveObject ( ms_poInterface, C_szWayTypeName, E_ss_Responsible, rWay.GetOwner() ),
|
|
CPA_EdMot<WP_tdhWay>(rWay)
|
|
{
|
|
|
|
m_lMode = rWay.m_lMode;
|
|
m_lWPInsertBefore = rWay.m_lWPInsertBefore;
|
|
m_xLBeam = rWay.m_xLBeam;
|
|
m_cDefaultLink=rWay.m_cDefaultLink;
|
|
m_pOldLink=rWay.m_pOldLink;
|
|
m_bRecreate=rWay.m_bRecreate;
|
|
m_bRotationMode=rWay.m_bRotationMode;
|
|
m_eWayDisplay=rWay.m_eWayDisplay;
|
|
|
|
|
|
// register in the list
|
|
ms_oListOfWay.AddTail (this);
|
|
|
|
|
|
// section object
|
|
SetSectionData ( this ) ;
|
|
SetCallBackSave ( fn_vCallbackSave ) ;
|
|
SetDataPath ( fn_szGetLevelsDataPath() ) ;
|
|
|
|
SetReferencedSectionName ( rWay.GetReferencedSectionName() );
|
|
|
|
// name
|
|
if ( fn_eRename (rWay.GetName() ) != E_mc_None)
|
|
SetDefaultValidName ( ) ;
|
|
|
|
fn_vUpdateSectionName ( ) ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
Way::~Way (void)
|
|
{
|
|
POSITION DeletePos = ms_oListOfWay.Find( this );
|
|
ms_oListOfWay.RemoveAt (DeletePos);
|
|
}
|
|
|
|
|
|
Way& Way::operator= (Way& rWay )
|
|
{
|
|
WP_fnv_Way_Copy ( (WP_tdhWay)GetData(), (WP_tdhWay)rWay.GetData() );
|
|
|
|
m_lMode = rWay.m_lMode;
|
|
m_lWPInsertBefore = rWay.m_lWPInsertBefore;
|
|
m_xLBeam = rWay.m_xLBeam;
|
|
m_cDefaultLink=rWay.m_cDefaultLink;
|
|
m_pOldLink=rWay.m_pOldLink;
|
|
m_bRecreate=rWay.m_bRecreate;
|
|
m_eWayDisplay=rWay.m_eWayDisplay;
|
|
ms_oListOfWay.AddTail (this);
|
|
|
|
fn_vLoadFromEngine ();
|
|
|
|
return *this;
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data
|
|
//-------------------------------------------------------------------
|
|
long Way::GetDataType (void)
|
|
{
|
|
return C_ucWay;
|
|
}
|
|
|
|
void* Way::GetData (void)
|
|
{
|
|
return GetStruct();
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Save
|
|
//-------------------------------------------------------------------
|
|
void Way::fn_vNotifySave (void)
|
|
{
|
|
if (m_bRecreate)
|
|
{
|
|
fn_vRestoreSection ();
|
|
m_bRecreate=FALSE;
|
|
}
|
|
CPA_SaveObject::fn_vNotifySave ();
|
|
fn_vNotifyAllEdtList ();
|
|
}
|
|
|
|
void Way::fn_vNotifyUnSave (void)
|
|
{
|
|
CPA_SaveObject::fn_vNotifyUnSave ();
|
|
fn_vNotifyAllEdtList ();
|
|
}
|
|
|
|
void Way::fn_vNotifyRestore (void)
|
|
{
|
|
CPA_SaveObject::fn_vNotifyRestore ();
|
|
fn_vNotifyAllEdtList ();
|
|
}
|
|
|
|
void Way::fn_vNotifyRename (void)
|
|
{
|
|
CPA_SaveObject::fn_vNotifyRename ();
|
|
fn_vNotifyAllEdtList ();
|
|
}
|
|
|
|
void Way::fn_vUpdateReference (CPA_SaveObject *pReferencedObject)
|
|
{
|
|
CPA_SaveObject::fn_vUpdateReference ( pReferencedObject );
|
|
fn_vNotifyAllEdtList ();
|
|
}
|
|
|
|
void Way::fn_vLoadFromEngine (void)
|
|
{
|
|
m_WaypointList.RemoveAll ();
|
|
m_LinkList.RemoveAll ();
|
|
|
|
WP_tdhWay hWay = GetStruct();
|
|
WP_tdhLink hLink;
|
|
|
|
// init the waypoint list
|
|
long lMaxCounter = WP_fnuc_Way_GetSizeWay(hWay);
|
|
for ( long lCounter =0; lCounter<lMaxCounter; lCounter++ )
|
|
{
|
|
WP_tdhWayPoint hWaypoint = WP_fnh_Way_GetElementFromWayPointArray (hWay,(unsigned char)lCounter);
|
|
CPA_BaseObject* poBaseObject = GetInterface()->GetMainWorld()->fn_p_oFindObjectWithEngine (hWaypoint);//, C_szDLLWayPointName);
|
|
ASSERT ( poBaseObject );
|
|
m_WaypointList.AddTail ( (WayPoint*) poBaseObject );
|
|
}
|
|
|
|
lMaxCounter = WP_fnuc_Way_GetSizeWay ( hWay )-1;
|
|
for ( lCounter=0; lCounter<lMaxCounter; lCounter++ )
|
|
{
|
|
hLink = WP_fnh_Way_GetElementFromLinkArray (hWay,(WP_tduc_WPIndex)lCounter);
|
|
Link* poLink = Link::fn_pCreateLink ( this, hLink ,fn_pGetWayPoint (lCounter), fn_pGetWayPoint (lCounter+1) );
|
|
poLink->fn_vSetAddInHierarchy (TRUE);
|
|
m_LinkList.AddTail ( poLink );
|
|
}
|
|
fn_vComputeLocation ();
|
|
|
|
fn_vRefresh (TRUE,FALSE);
|
|
}
|
|
|
|
|
|
//---------------------------------------------- Set
|
|
void Way::fn_vSetSelectWayPoint (long lSelectWP)
|
|
{
|
|
m_lSelectWP=lSelectWP;
|
|
}
|
|
|
|
|
|
void Way::fn_vSetRotationMode (BOOL bRotationMode)
|
|
{
|
|
if (m_bRotationMode == bRotationMode) return;
|
|
|
|
POSITION xLinkPos;
|
|
Link* poLink;
|
|
|
|
for (poLink=m_LinkList.GetHeadElement(xLinkPos); poLink; poLink=m_LinkList.GetNextElement(xLinkPos) )
|
|
poLink->fn_vRotationGraphic (bRotationMode);
|
|
|
|
m_bRotationMode = bRotationMode;
|
|
GetInterface()->fn_vSwapLinkDialog ( bRotationMode );
|
|
fn_vDraw ();
|
|
GetInterface()->GetInterface()->fn_vUpdateAll (E_mc_JustDraw);
|
|
}
|
|
|
|
|
|
//---------------------------------------------- Get
|
|
long Way::fn_lGetSelectWayPoint (void)
|
|
{
|
|
return m_lSelectWP;
|
|
}
|
|
|
|
|
|
//---------------------------------------------------------------------
|
|
BOOL Way::fn_bIsDialog (void)
|
|
{
|
|
return ms_poDiaWay->fn_bIsEdit (this);
|
|
}
|
|
|
|
|
|
BOOL Way::fn_vClicWayPoint (WayPoint* poWP1, WayPoint* poWP2)
|
|
{
|
|
long lPosWP = fn_iIsWayPointInNet(poWP1,poWP2);
|
|
if (lPosWP<0) return FALSE;
|
|
m_lSelectWP=lPosWP;
|
|
if (fn_bIsDialog())
|
|
fn_pGetDialog()->fn_vSelectWPInList (lPosWP);
|
|
GetInterface()->fn_vEdit (poWP1);
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL Way::fn_bIsRedrawWay (WayPoint* poSearchWP)
|
|
{
|
|
BOOL bRet=FALSE;
|
|
POSITION lPos;
|
|
WayPoint* poWP;
|
|
Link* poLink;
|
|
|
|
int iIndice;
|
|
for
|
|
(
|
|
poWP=m_WaypointList.GetHeadElement(lPos), iIndice=0;
|
|
poWP;
|
|
poWP=m_WaypointList.GetNextElement(lPos),iIndice++
|
|
)
|
|
if (poWP==poSearchWP)
|
|
{
|
|
bRet=TRUE;
|
|
poLink = fn_pGetLink (iIndice-1);
|
|
if (poLink) poLink->fn_vSetDraw (TRUE);
|
|
poLink = fn_pGetLink (iIndice);
|
|
if (poLink) poLink->fn_vSetDraw (TRUE);
|
|
}
|
|
return bRet;
|
|
}
|
|
|
|
BOOL Way::fn_vAddWayPoint (WayPoint* poWP)
|
|
{
|
|
if (!poWP->fn_bGetCoordinate()) return FALSE;
|
|
POSITION xPos;
|
|
if (m_WaypointList.GetTailElement (xPos)==poWP) return FALSE;
|
|
fn_vInsBeforeWP (poWP, m_WaypointList.GetCount());
|
|
return TRUE;
|
|
}
|
|
|
|
void Way::fn_vDeleteWayPoint(void)
|
|
{
|
|
fn_vSupWP (m_lSelectWP);
|
|
}
|
|
|
|
void Way::fn_vRemoveWayPoint (WayPoint* poWP)
|
|
{
|
|
if (fn_iIsWayPointInNet (poWP)<0) return;
|
|
GetInterface()->GetInterface()->GetMultiDevice()->GetEditManager()->AskFor (new ModifWayRemove (this, poWP, TRUE));
|
|
fn_bIsValid (TRUE);
|
|
}
|
|
|
|
BOOL Way::fn_vInsertWayPoint(WayPoint* poWP, BOOL bBlock)
|
|
{
|
|
if (!poWP->fn_bGetCoordinate()) return FALSE;
|
|
if (m_pOldLink)
|
|
{
|
|
GetInterface()->GetInterface()->fn_bInsertObjectInHierarchy (m_pOldLink->GetSuperObject(), GetSuperObject(),FALSE,FALSE,FALSE);
|
|
m_pOldLink=NULL;
|
|
}
|
|
fn_vInsBeforeWP (poWP, m_lWPInsertBefore, TRUE, bBlock);
|
|
fn_bIsValid (TRUE);
|
|
return TRUE;
|
|
}
|
|
|
|
void Way::fn_vInsertNewWayPoint (MTH3D_tdstVector* pAbsolutePosition)
|
|
{
|
|
if (m_pOldLink)
|
|
{
|
|
GetInterface()->GetInterface()->fn_bInsertObjectInHierarchy (m_pOldLink->GetSuperObject(), GetSuperObject(),FALSE,FALSE,FALSE);
|
|
m_pOldLink=NULL;
|
|
}
|
|
|
|
GetInterface()->GetInterface()->GetMultiDevice()->GetEditManager()->AskFor (new ModifWayAddWP ( this, pAbsolutePosition, (char)m_lWPInsertBefore, GetInterface()->GetInterface() ));
|
|
fn_bIsValid (TRUE);
|
|
}
|
|
|
|
int Way::fn_iIsWayPointInNet (WayPoint* poSearchWP,WayPoint* poNextSearchWP)
|
|
{
|
|
POSITION lPos;
|
|
WayPoint *poWP, *poNextWP;
|
|
int iIndice;
|
|
BOOL bNotNext=TRUE;
|
|
|
|
for
|
|
(
|
|
poWP=m_WaypointList.GetHeadElement(lPos),
|
|
poNextWP=m_WaypointList.GetNextElement(lPos),
|
|
iIndice=0;
|
|
poWP;
|
|
iIndice++, poWP=poNextWP, poNextWP = m_WaypointList.GetNextElement(lPos)
|
|
)
|
|
if (poWP==poSearchWP)
|
|
{
|
|
if (!poNextSearchWP) return iIndice;
|
|
if (poNextWP==poNextSearchWP) return iIndice;
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
int Way::fn_iSearchLinkInWay (Link* poSearchLink)
|
|
{
|
|
POSITION lPos;
|
|
Link* poLink;
|
|
int iIndice;
|
|
for
|
|
(
|
|
poLink=m_LinkList.GetHeadElement(lPos), iIndice=0;
|
|
poLink && poLink!=poSearchLink;
|
|
poLink=m_LinkList.GetNextElement(lPos),iIndice++
|
|
);
|
|
if (poLink) return iIndice;
|
|
else return -1;
|
|
}
|
|
|
|
|
|
void Way::fn_vSupWP (long lPosDelWP, BOOL bBlock)
|
|
{
|
|
GetInterface()->GetInterface()->GetMultiDevice()->GetEditManager()->AskFor (new ModifWayDelete (this, (char)lPosDelWP, bBlock));
|
|
fn_bIsValid (TRUE);
|
|
}
|
|
|
|
BOOL Way::fn_vInsBeforeWP (WayPoint* poInsWP, long lBeforeWP, BOOL bDialog1stRefresh, BOOL bBlock)
|
|
{
|
|
if (!poInsWP->fn_bGetCoordinate()) return FALSE;
|
|
GetInterface()->GetInterface()->GetMultiDevice()->GetEditManager()->AskFor (new ModifWayInsert (this, poInsWP, (char)lBeforeWP, bDialog1stRefresh, bBlock));
|
|
fn_bIsValid (TRUE);
|
|
return TRUE;
|
|
}
|
|
|
|
long Way::fn_lGetWPName (char (**dszName) [30])
|
|
{
|
|
long lNbWPInNet=m_WaypointList.GetCount();
|
|
long lIndex;
|
|
POSITION lPos;
|
|
WayPoint* poWP=NULL;
|
|
*dszName = new char [lNbWPInNet][30];
|
|
for (poWP=m_WaypointList.GetHeadElement(lPos), lIndex=0; poWP; poWP=m_WaypointList.GetNextElement(lPos), lIndex++)
|
|
strcpy ((*dszName)[lIndex], poWP->GetName () );
|
|
return lIndex;
|
|
}
|
|
|
|
WayPoint* Way::fn_pGetWayPoint (char* pszNameWP)
|
|
{
|
|
POSITION lPos;
|
|
WayPoint* poWP;
|
|
for
|
|
(
|
|
poWP=m_WaypointList.GetHeadElement(lPos);
|
|
poWP && strcmp ( poWP->GetSuperObject()->GetName(), pszNameWP );
|
|
poWP=m_WaypointList.GetNextElement(lPos)
|
|
);
|
|
return poWP;
|
|
}
|
|
|
|
WayPoint* Way::fn_pGetWayPoint (long lIndice)
|
|
{
|
|
long lIndex;
|
|
POSITION lPos;
|
|
WayPoint* poWP;
|
|
for (poWP=m_WaypointList.GetHeadElement(lPos), lIndex=0; poWP && lIndex!=lIndice; poWP=m_WaypointList.GetNextElement(lPos), lIndex++);
|
|
if (poWP) return poWP;
|
|
else return NULL;
|
|
}
|
|
|
|
Link* Way::fn_pGetLink (long lIndice)
|
|
{
|
|
long lIndex;
|
|
POSITION lPos;
|
|
Link* poLink=NULL;
|
|
if (lIndice<0) return NULL;
|
|
for (poLink=m_LinkList.GetHeadElement(lPos), lIndex=0; poLink && lIndex!=lIndice; poLink=m_LinkList.GetNextElement(lPos), lIndex++);
|
|
return poLink;
|
|
}
|
|
|
|
|
|
CPA_SuperObject* Way::fn_pCreateLink (char cType)
|
|
{
|
|
return Link::fn_pCreateLink ( this, cType )->GetSuperObject ();
|
|
}
|
|
|
|
Link* Way::fn_pPrevLink (Link* pLink)
|
|
{
|
|
int iPos = fn_iSearchLinkInWay (pLink);
|
|
return fn_pGetLink (iPos-1);
|
|
}
|
|
|
|
Link* Way::fn_pNextLink (Link* pLink)
|
|
{
|
|
int iPos = fn_iSearchLinkInWay (pLink);
|
|
return fn_pGetLink (iPos+1);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------
|
|
// Selection
|
|
//---------------------------------------------------------------------
|
|
void Way::fn_vSelectAllWP (void)
|
|
{
|
|
POSITION lPos;
|
|
WayPoint* poWP;
|
|
for
|
|
(
|
|
poWP=m_WaypointList.GetHeadElement(lPos);
|
|
poWP;
|
|
poWP=m_WaypointList.GetNextElement(lPos)
|
|
)
|
|
GetInterface()->GetInterface()->fn_vAddSelectedObject ( poWP->GetSuperObject(), FALSE);
|
|
}
|
|
|
|
void Way::fn_vUnselectAllWP (void)
|
|
{
|
|
POSITION lPos;
|
|
WayPoint* poWP;
|
|
for
|
|
(
|
|
poWP=m_WaypointList.GetHeadElement(lPos);
|
|
poWP;
|
|
poWP=m_WaypointList.GetNextElement(lPos)
|
|
)
|
|
GetInterface()->GetInterface()->fn_vRemoveSelectedObject (poWP->GetSuperObject(),FALSE);
|
|
}
|
|
|
|
|
|
//---------------------------------------------------------------------
|
|
// Modes
|
|
//---------------------------------------------------------------------
|
|
void Way::fn_vModeNormal (void)
|
|
{
|
|
m_lMode = c_Way_Normal;
|
|
m_lWPInsertBefore = 0;
|
|
|
|
if (m_pLinkBefore)
|
|
{
|
|
GetInterface()->fn_vSetModifDeleteOk (TRUE);
|
|
GetInterface()->GetInterface()->fn_bDeleteObjectInHierarchy (m_pLinkBefore->GetSuperObject(),FALSE,FALSE,FALSE,FALSE);
|
|
GetInterface()->fn_vSetModifDeleteOk (FALSE);
|
|
m_pLinkBefore->fn_vSetRemoveInHierarchy (TRUE);
|
|
m_pLinkBefore=NULL;
|
|
}
|
|
|
|
if (m_pLinkAfter)
|
|
{
|
|
GetInterface()->fn_vSetModifDeleteOk (TRUE);
|
|
GetInterface()->GetInterface()->fn_bDeleteObjectInHierarchy (m_pLinkAfter->GetSuperObject(),FALSE,FALSE,FALSE,FALSE);
|
|
GetInterface()->fn_vSetModifDeleteOk (FALSE);
|
|
m_pLinkAfter->fn_vSetRemoveInHierarchy (TRUE);
|
|
m_pLinkAfter=NULL;
|
|
}
|
|
}
|
|
|
|
void Way::fn_vModeInsert (Link* poLink, MTH3D_tdstVector* pxPosMouse)
|
|
{
|
|
if (m_lMode == c_Way_InsertWP) return;
|
|
tdeLocalColor eColor = GetSuperObject()->GetLocalColor ();
|
|
|
|
WP_fnv_WayPoint_SetVertex ( (WP_tdhWayPoint)m_poVirtualWP->GetEngineStruct() , pxPosMouse);
|
|
|
|
m_lWPInsertBefore=fn_iSearchLinkInWay (poLink)+1;
|
|
m_pOldLink=poLink;
|
|
|
|
poLink->fn_vSplitLink ( this, m_poVirtualWP, &m_pLinkBefore, &m_pLinkAfter );
|
|
|
|
GetInterface()->GetInterface()->fn_bInsertObjectInHierarchy (m_pLinkBefore->GetSuperObject(), GetSuperObject(),FALSE,FALSE,FALSE);
|
|
GetInterface()->GetInterface()->fn_bInsertObjectInHierarchy (m_pLinkAfter->GetSuperObject(), GetSuperObject(),FALSE,FALSE,FALSE);
|
|
|
|
// clear the split link
|
|
GetInterface()->fn_vSetModifDeleteOk (TRUE);
|
|
GetInterface()->GetInterface()->fn_bDeleteObjectInHierarchy (poLink->GetSuperObject(),FALSE,FALSE,FALSE,FALSE);
|
|
GetInterface()->fn_vSetModifDeleteOk (FALSE);
|
|
|
|
fn_vRefresh ();
|
|
}
|
|
|
|
|
|
BOOL Way::fn_vModeAdd (MTH3D_tdstVector* pxPosMouse)
|
|
{
|
|
if (m_lMode == c_Way_Add) return FALSE;
|
|
m_lMode = c_Way_Add;
|
|
if (m_WaypointList.GetCount()<=0) return FALSE;
|
|
|
|
// tell the net the position to insert the WP
|
|
m_lWPInsertBefore=m_WaypointList.GetCount();
|
|
|
|
if (pxPosMouse)
|
|
{
|
|
WP_fnv_WayPoint_SetVertex ( (WP_tdhWayPoint)m_poVirtualWP->GetEngineStruct() , pxPosMouse);
|
|
}
|
|
else (*m_poVirtualWP) = *(m_WaypointList.GetTail());
|
|
|
|
m_pLinkBefore = Link::fn_pCreateLink ( this, WP_ConnType_ucStaticLine, m_WaypointList.GetTail(), m_poVirtualWP );
|
|
m_pLinkBefore->fn_vSetDraw (FALSE);
|
|
m_pLinkAfter = NULL;
|
|
m_pOldLink = NULL;
|
|
|
|
|
|
GetInterface()->GetInterface()->fn_bInsertObjectInHierarchy (m_pLinkBefore->GetSuperObject(), GetSuperObject(),FALSE,FALSE,FALSE);
|
|
|
|
m_pLinkBefore->fn_vDraw ();
|
|
|
|
// redraw the world
|
|
GetInterface()->GetInterface()->fn_vUpdateAll (E_mc_JustDraw);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void Way::fn_vAddAtTheEnd (void)
|
|
{
|
|
m_lWPInsertBefore=0;
|
|
}
|
|
|
|
void Way::fn_vStopModeAdd (void)
|
|
{
|
|
m_lMode = c_Way_Normal;
|
|
|
|
GetInterface()->fn_vSetModifDeleteOk (TRUE);
|
|
GetInterface()->GetInterface()->fn_bDeleteObjectInHierarchy (m_pLinkBefore->GetSuperObject(),FALSE,FALSE,FALSE,FALSE);
|
|
GetInterface()->fn_vSetModifDeleteOk (FALSE);
|
|
m_pLinkBefore->fn_vSetRemoveInHierarchy (TRUE);
|
|
m_pLinkBefore=NULL;
|
|
GetInterface()->GetInterface()->fn_vUpdateAll (E_mc_JustDraw);
|
|
}
|
|
|
|
|
|
void Way::fn_vDrawMouseLine (MTH3D_tdstVector* pxPosMouse)
|
|
{
|
|
WayPoint *WP1, *WP2, *WP3, *WP4;
|
|
MTH3D_tdstVector stVertex;
|
|
|
|
m_pLinkBefore->fn_vGetWaypoints ( &WP1, &WP2 );
|
|
m_pLinkAfter->fn_vGetWaypoints ( &WP3, &WP4 );
|
|
|
|
WP_fnv_WayPoint_GetVertex ((WP_tdhWayPoint)WP2->GetEngineStruct(), &stVertex);
|
|
MTH3D_M_vAddVector(&stVertex, &stVertex, pxPosMouse);
|
|
WP_fnv_WayPoint_SetVertex ( (WP_tdhWayPoint)WP2->GetEngineStruct() , &stVertex);
|
|
|
|
m_pLinkBefore->fn_vDraw ();
|
|
m_pLinkAfter->fn_vDraw ();
|
|
|
|
GetInterface()->GetInterface()->fn_vUpdateAll (E_mc_JustDraw);
|
|
}
|
|
|
|
void Way::fn_vDrawElastic (MTH3D_tdstVector* pxPosMouse)
|
|
{
|
|
if (!m_pLinkBefore) return;
|
|
|
|
WayPoint *WP1, *WP2;
|
|
MTH3D_tdstVector stVertex;
|
|
|
|
m_pLinkBefore->fn_vGetWaypoints ( &WP1, &WP2 );
|
|
WP_fnv_WayPoint_GetVertex ((WP_tdhWayPoint)WP2->GetEngineStruct(), &stVertex);
|
|
MTH3D_M_vAddVector(&stVertex, &stVertex, pxPosMouse);
|
|
WP_fnv_WayPoint_SetVertex ( (WP_tdhWayPoint)WP2->GetEngineStruct() , &stVertex);
|
|
|
|
m_pLinkBefore->fn_vDraw ();
|
|
|
|
GetInterface()->GetInterface()->fn_vUpdateAll (E_mc_JustDraw);
|
|
}
|
|
|
|
|
|
BOOL Way::fn_bIsWayDrawable (void)
|
|
{
|
|
switch (ms_eWayDisplay)
|
|
{
|
|
case eWayDisplayOn : return TRUE;
|
|
case eWayDisplayOff : return FALSE;
|
|
case eWayDisplaySelected :
|
|
{
|
|
// there is no actor selected
|
|
if (GetInterface()->fn_pGetSelectedInstance())
|
|
{
|
|
switch ( (tdeWayDisplay) ( GetInterface()->fn_poGetEdtListUseByActor ( GetInterface()->fn_pGetSelectedInstance() ) )->fn_lGetDrawObjects () )
|
|
{
|
|
case eWayDisplayOn : return TRUE;
|
|
case eWayDisplayOff : return FALSE;
|
|
}
|
|
}
|
|
|
|
switch (m_eWayDisplay)
|
|
{
|
|
case eWayDisplayOn : return TRUE;
|
|
case eWayDisplayOff : return FALSE;
|
|
case eWayDisplaySelected : return FALSE;
|
|
}
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
// !!! recursive function because it's call again in fn_vSupWP
|
|
BOOL Way::fn_bIsValid (BOOL bCorrect)
|
|
{
|
|
// is there a double-WP ?
|
|
POSITION lPos;
|
|
WayPoint *poWP, *poOldWP;
|
|
poOldWP=NULL;
|
|
BOOL bValid=TRUE;
|
|
long lIndice;
|
|
for (poWP=m_WaypointList.GetHeadElement(lPos), lIndice=0; poWP; poOldWP=poWP, poWP=m_WaypointList.GetNextElement(lPos), lIndice++ )
|
|
if (poWP==poOldWP)
|
|
{
|
|
if (bCorrect) fn_vSupWP (lIndice,TRUE);
|
|
return FALSE;
|
|
}
|
|
|
|
// Are all the Waypoint static ?
|
|
for (poWP=m_WaypointList.GetHeadElement(lPos), lIndice=0; poWP; poWP=m_WaypointList.GetNextElement(lPos), lIndice++ )
|
|
{
|
|
if (!poWP->fn_bGetCoordinate())
|
|
// this WP is dynamic -> delete in the net or change its state ?
|
|
{
|
|
if (bCorrect)
|
|
{
|
|
fn_vSupWP (lIndice,TRUE); // pour le moment
|
|
}
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
// here if there's other criteres to correct
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL Way::fn_bConnect ( Way* poWay, CPA_List<WayPoint>* poList )
|
|
{
|
|
POSITION xPos;
|
|
WayPoint* poWaypoint;
|
|
BOOL bConnect=FALSE;
|
|
|
|
if (poWay==this) return FALSE;
|
|
|
|
for ( poWaypoint=m_WaypointList.GetHeadElement(xPos); poWaypoint; poWaypoint=m_WaypointList.GetNextElement(xPos) )
|
|
if ( poWay->GetListWaypoint()->Find (poWaypoint)>=0 )
|
|
{
|
|
poWay->fn_bIsRedrawWay (poWaypoint);
|
|
poList->AddTail (poWaypoint);
|
|
bConnect=TRUE;
|
|
}
|
|
return bConnect;
|
|
}
|
|
|
|
void Way::fn_vEmptyWay (void)
|
|
{
|
|
long lNbWPInWay = m_WaypointList.GetCount();
|
|
long lCounter;
|
|
|
|
for ( lCounter=0; lCounter<lNbWPInWay; lCounter++)
|
|
{
|
|
WayPoint* poWaypoint = fn_pGetWayPoint (0L);
|
|
GetInterface()->GetInterface()->GetMultiDevice()->GetEditManager()->AskFor (new ModifWayDelete (this, 0, TRUE));
|
|
|
|
// delete waypoint ?
|
|
if (!poWaypoint->fn_bIsAlone())
|
|
{
|
|
// waypoint use in another way ?
|
|
POSITION xWayPos;
|
|
Way* poWay;
|
|
BOOL bDeleteWaypoint=TRUE;
|
|
|
|
for ( poWay=ms_oListOfWay.GetHeadElement(xWayPos); poWay; poWay=ms_oListOfWay.GetNextElement(xWayPos) )
|
|
if (poWay->fn_iIsWayPointInNet (poWaypoint)>=0) bDeleteWaypoint=FALSE;
|
|
|
|
if (bDeleteWaypoint && !poWaypoint->fn_bIsReferencedInAI())
|
|
{
|
|
GetInterface()->fn_vSetRefreshWay (TRUE);
|
|
GetInterface()->GetInterface()->fn_bDeleteObjectInHierarchy (poWaypoint->GetSuperObject(), TRUE, FALSE, FALSE, FALSE, TRUE);
|
|
GetInterface()->fn_vSetRefreshWay (FALSE);
|
|
}
|
|
}
|
|
}
|
|
m_lWPInsertBefore=0;
|
|
}
|
|
|
|
void Way::fn_vRefresh (BOOL bDeleteMark, BOOL bDraw)
|
|
{
|
|
POSITION lPos;
|
|
Link* poLink;
|
|
CPA_SuperObject* poSuperObject;
|
|
|
|
CPA_List<CPA_SuperObject> oListObjetctToDelete;
|
|
|
|
// Add the links in the hierarchy
|
|
for (poLink=m_LinkList.GetHeadElement(lPos); poLink; poLink=m_LinkList.GetNextElement(lPos) )
|
|
{
|
|
if (poLink->fn_bIsAddInHierarchy())
|
|
{
|
|
if (!GetInterface()->GetInterface()->fn_bInsertObjectInHierarchy ( poLink->GetSuperObject(), GetSuperObject(), FALSE, FALSE, FALSE ))
|
|
GetSuperObject()->AddTail (poLink->GetSuperObject());
|
|
GetInterface()->fn_vComputeAbsoluteMatrix (poLink->GetSuperObject());
|
|
poLink->fn_vSetAddInHierarchy (FALSE);
|
|
poLink->fn_vInitGraphic(); // call the init function for graphics
|
|
poLink->fn_vSetDraw (TRUE); // The new link must be redraw
|
|
}
|
|
}
|
|
|
|
// Redraw if usefull
|
|
for
|
|
(
|
|
poSuperObject = (CPA_SuperObject*)(GetSuperObject()->GetHeadElement (lPos));
|
|
poSuperObject;
|
|
poSuperObject = (CPA_SuperObject*)(GetSuperObject()->GetNextElement (lPos))
|
|
)
|
|
{
|
|
poLink = (Link*) (poSuperObject->GetObject());
|
|
|
|
// this link is in the hierachy was deleted from the way
|
|
if (poLink->fn_bIsRemoveInHierarchy())
|
|
{
|
|
oListObjetctToDelete.AddTail (poLink->GetSuperObject());
|
|
poLink->fn_vSetRemoveInHierarchy (FALSE);
|
|
}
|
|
|
|
// this link must be redraw
|
|
else if (poLink->fn_bIsDraw())
|
|
{
|
|
poLink->fn_vDraw ();
|
|
if (bDeleteMark) poLink->fn_vSetDraw (FALSE);
|
|
}
|
|
}
|
|
|
|
// Delete for real
|
|
GetInterface()->fn_vSetModifDeleteOk (TRUE);
|
|
for
|
|
(
|
|
poSuperObject = oListObjetctToDelete.GetHeadElement (lPos);
|
|
poSuperObject;
|
|
poSuperObject = oListObjetctToDelete.GetNextElement (lPos)
|
|
)
|
|
|
|
if (!GetInterface()->GetInterface()->fn_bDeleteObjectInHierarchy (poSuperObject,FALSE,FALSE,FALSE,FALSE))
|
|
{
|
|
POSITION xDelPos;
|
|
xDelPos = GetSuperObject()->Find (poSuperObject);
|
|
GetSuperObject()->RemoveAt (xDelPos);
|
|
}
|
|
|
|
GetInterface()->fn_vSetModifDeleteOk (FALSE);
|
|
if (bDraw) GetInterface()->GetInterface()->fn_vUpdateAll (E_mc_JustDraw);
|
|
}
|
|
|
|
void Way::fn_vDraw (void)
|
|
{
|
|
POSITION lPos;
|
|
Link* poLink;
|
|
|
|
for (poLink=m_LinkList.GetHeadElement(lPos); poLink; poLink=m_LinkList.GetNextElement(lPos) )
|
|
poLink->fn_vDraw ();
|
|
}
|
|
|
|
BOOL Way::fn_bChangeLink ( Link* pOldLink, Link* pNewLink )
|
|
{
|
|
POSITION lPos;
|
|
Link* poLink;
|
|
int iIndice;
|
|
for
|
|
(
|
|
poLink=m_LinkList.GetHeadElement(lPos), iIndice=0;
|
|
poLink && poLink!=pOldLink;
|
|
poLink=m_LinkList.GetNextElement(lPos),iIndice++
|
|
);
|
|
if (!poLink) return FALSE;
|
|
|
|
pOldLink->fn_vWayNotifySave ();
|
|
pNewLink->fn_vWayNotifySave ();
|
|
|
|
pOldLink->fn_vStopEdit ();
|
|
GetInterface()->fn_vSetModifDeleteOk (TRUE);
|
|
GetInterface()->GetInterface()->fn_bDeleteObjectInHierarchy ( pOldLink->GetSuperObject(),FALSE,FALSE,FALSE,FALSE );
|
|
GetInterface()->fn_vSetModifDeleteOk (FALSE);
|
|
|
|
GetInterface()->GetInterface()->fn_bInsertObjectInHierarchy ( pNewLink->GetSuperObject(), GetSuperObject(),FALSE,FALSE, FALSE );
|
|
m_LinkList.SetAt ( lPos, pNewLink );
|
|
GetInterface()->fn_vComputeAbsoluteMatrix (pNewLink->GetSuperObject());
|
|
|
|
// change engine data
|
|
WP_fnv_Way_SetElementFromLinkArray ( (WP_tdhWay)GetData(), iIndice, (WP_tdhLink)pNewLink->GetData() );
|
|
// WP_fnv_Link_ChangeConnectionTypeBezier ( (WP_tdhLink)pNewLink->GetData(), EDWAY_fnh_BezierObject_GetBezierCurve(pNewLink->fn_hGetEditBezierObject()) );
|
|
|
|
|
|
|
|
pNewLink->fn_vInitGraphic ();
|
|
pNewLink->fn_vStartEdit (),
|
|
pNewLink->fn_vDraw ();
|
|
pNewLink->fn_vSetDrawOutHierarchy (TRUE);
|
|
|
|
GetInterface()->GetInterface()->fn_vUpdateAll (E_mc_JustDraw);
|
|
return TRUE;
|
|
}
|
|
|
|
void Way::fn_vChangeAllOrientationTangent (MTH3D_tdstVector* pTangentVertex)
|
|
{
|
|
POSITION xPos;
|
|
Link* poLink;
|
|
|
|
for (poLink=m_LinkList.GetHeadElement(xPos); poLink; poLink=m_LinkList.GetNextElement(xPos) )
|
|
poLink->fn_vSetAllOrientationTangent (pTangentVertex);
|
|
GetInterface()->GetInterface()->fn_vUpdateAll (E_mc_JustDraw);
|
|
}
|
|
|
|
void Way::fn_vSetWaypointOnScreen (BOOL bOnScreen)
|
|
{
|
|
POSITION xPos;
|
|
WayPoint* poWaypoint;
|
|
|
|
for ( poWaypoint = m_WaypointList.GetHeadElement(xPos); poWaypoint; poWaypoint = m_WaypointList.GetNextElement(xPos) )
|
|
poWaypoint->fn_vSetOnScreen (bOnScreen);
|
|
}
|
|
|
|
void Way::fn_vNotifyAllEdtList (void)
|
|
{
|
|
CPA_BaseObjectList* poListOfEdtList = GetInterface()->GetInterface()->GetMainWorld()->fn_p_oGetOriginalObjectList (C_szEdtListTypeName);
|
|
|
|
Position xEdtListPos;
|
|
CPA_BaseObject* poBaseObject;
|
|
|
|
for ( poBaseObject=poListOfEdtList->GetHeadElement (xEdtListPos); poBaseObject; poBaseObject=poListOfEdtList->GetNextElement (xEdtListPos) )
|
|
{
|
|
// notify this EdtList ?
|
|
BOOL bNotify=FALSE;
|
|
EdtList* poEdtList = (EdtList*) poBaseObject;
|
|
|
|
if (poEdtList->fn_csGetListType()==C_szWayName)
|
|
{
|
|
POSITION xWayPos;
|
|
CPA_BaseObject* poObject;
|
|
|
|
for ( poObject = poEdtList->GetHeadElement (xWayPos); poObject && !bNotify; poObject = poEdtList->GetNextElement (xWayPos) )
|
|
if (poObject==this) bNotify=TRUE;
|
|
|
|
if (bNotify) poEdtList->fn_vNotifySave ();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
long Way::fn_lGetShareMode (void)
|
|
{
|
|
Position xPos;
|
|
CPA_BaseObject* poBaseObject;
|
|
long lCounter=0;
|
|
|
|
CPA_BaseObjectList* poList = GetInterface()->GetInterface()->GetMainWorld()->fn_p_oGetOriginalObjectList (C_szEdtListTypeName);
|
|
|
|
|
|
|
|
for (poBaseObject=poList->GetHeadElement (xPos); poBaseObject; poBaseObject=poList->GetNextElement (xPos) )
|
|
{
|
|
EdtList* poEdtList = (EdtList*) poBaseObject;
|
|
// on garde que le bon type
|
|
|
|
if (poEdtList->fn_csGetListType()==C_szWayName)
|
|
{
|
|
POSITION xBasePos;
|
|
CPA_BaseObject* poObject;
|
|
for ( poObject=poEdtList->GetHeadElement(xBasePos), lCounter=0 ; poObject && poObject!=this; poObject=poEdtList->GetNextElement(xBasePos), lCounter++ );
|
|
|
|
// ok we have find
|
|
if (poObject)
|
|
{
|
|
CPA_tdoNameList* poNameList = poEdtList->fn_oGetNameList();
|
|
POSITION xNamePos = poEdtList->fn_oGetNameList()->FindIndex (lCounter);
|
|
tdoObjectName* poName = poNameList->GetAt (xNamePos);
|
|
return (long)poName->m_eGetShareMode();
|
|
}
|
|
}
|
|
}
|
|
ASSERT (FALSE);
|
|
return (long)E_sm_None;
|
|
}
|
|
|
|
|
|
BOOL Way::fn_bIsCommon (void)
|
|
{
|
|
return fn_lGetShareMode()==E_sm_Common;
|
|
}
|
|
|
|
|
|
long Way::fn_lUsedInEdtList (void)
|
|
{
|
|
Position xPos;
|
|
CPA_BaseObject* poBaseObject;
|
|
long lCounter=0;
|
|
|
|
CPA_BaseObjectList* poList = GetInterface()->GetInterface()->GetMainWorld()->fn_p_oGetOriginalObjectList (C_szEdtListTypeName);
|
|
|
|
|
|
for (poBaseObject=poList->GetHeadElement (xPos); poBaseObject; poBaseObject=poList->GetNextElement (xPos) )
|
|
{
|
|
EdtList* poEdtList = (EdtList*) poBaseObject;
|
|
|
|
POSITION xReachablePos;
|
|
CPA_BaseObject* poObject;
|
|
for ( poObject=poEdtList->GetHeadElement(xReachablePos); poObject; poObject=poEdtList->GetNextElement(xReachablePos) )
|
|
if (poObject==this) lCounter++;
|
|
}
|
|
return lCounter;
|
|
}
|
|
|
|
EdtList* Way::fn_pGetEdtList (void)
|
|
{
|
|
Position xPos;
|
|
CPA_BaseObject* poBaseObject;
|
|
long lCounter=0;
|
|
|
|
CPA_BaseObjectList* poList = GetInterface()->GetInterface()->GetMainWorld()->fn_p_oGetOriginalObjectList (C_szEdtListTypeName);
|
|
|
|
|
|
for (poBaseObject=poList->GetHeadElement (xPos); poBaseObject; poBaseObject=poList->GetNextElement (xPos) )
|
|
{
|
|
EdtList* poEdtList = (EdtList*) poBaseObject;
|
|
|
|
POSITION xReachablePos;
|
|
CPA_BaseObject* poObject;
|
|
for ( poObject=poEdtList->GetHeadElement(xReachablePos); poObject; poObject=poEdtList->GetNextElement(xReachablePos) )
|
|
if (poObject==this) return poEdtList;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
BOOL Way::fn_bWayInEdtList (EdtList* poEdtList)
|
|
{
|
|
|
|
POSITION xReachablePos;
|
|
CPA_BaseObject* poObject;
|
|
for ( poObject=poEdtList->GetHeadElement(xReachablePos); poObject; poObject=poEdtList->GetNextElement(xReachablePos) )
|
|
if (poObject==this) return TRUE;
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
CString Way::fn_csGetNameInNameList (void)
|
|
{
|
|
Position xPos;
|
|
CPA_BaseObject* poBaseObject;
|
|
long lCounter=0;
|
|
|
|
CPA_BaseObjectList* poList = GetInterface()->GetInterface()->GetMainWorld()->fn_p_oGetOriginalObjectList (C_szEdtListTypeName);
|
|
|
|
|
|
for (poBaseObject=poList->GetHeadElement (xPos); poBaseObject; poBaseObject=poList->GetNextElement (xPos) )
|
|
{
|
|
EdtList* poEdtList = (EdtList*) poBaseObject;
|
|
// on garde que le bon type
|
|
|
|
if (poEdtList->fn_csGetListType()==C_szWayName)
|
|
{
|
|
POSITION xReachablePos;
|
|
CPA_BaseObject* poWay;
|
|
for ( poWay=poEdtList->GetHeadElement(xReachablePos), lCounter=0 ; poWay && poWay!=this; poWay=poEdtList->GetNextElement(xReachablePos), lCounter++ );
|
|
|
|
// ok we have find
|
|
if (poWay)
|
|
{
|
|
POSITION xNamePos = poEdtList->fn_oGetNameList()->FindIndex (lCounter);
|
|
return poEdtList->fn_oGetNameList()->GetAt(xNamePos)->GetName();
|
|
}
|
|
}
|
|
}
|
|
ASSERT (FALSE);
|
|
return "";
|
|
}
|
|
|
|
void Way::fn_vCopy (void)
|
|
{
|
|
ms_poCopyWay = this;
|
|
}
|
|
|
|
void Way::fn_vPaste (void)
|
|
{
|
|
GetInterface()->fn_vSetRefreshWay (TRUE);
|
|
if (!GetSuperObject()->GetParent()) GetInterface()->GetInterface()->fn_bInsertObjectInHierarchy (GetSuperObject(), GetInterface()->GetInterface()->GetSpecificInterface()->GetDynamicRoot(),FALSE,FALSE, FALSE );
|
|
GetInterface()->fn_vSetRefreshWay (FALSE);
|
|
if (!ms_poCopyWay->IsWayEmpty()) (*this) = (*ms_poCopyWay);
|
|
GetInterface()->fn_vEdit (this);
|
|
GetInterface()->fn_vRefreshScreen ();
|
|
}
|
|
|
|
void Way::fn_vComputeLocation (void)
|
|
{
|
|
MTH3D_tdstVector stVertexLocation;
|
|
if (IsWayEmpty()) return;
|
|
WayPoint* poWaypoint = m_WaypointList.GetHead();
|
|
|
|
WP_fnv_WayPoint_ComputeLocation ( (WP_tdhWayPoint)(poWaypoint->GetData()),&stVertexLocation );
|
|
GEO_tdxHandleToMatrix hAbsoluteMatrix = HIE_fn_hGetSuperObjectGlobalMatrix (GetSuperObject()->GetStruct());
|
|
POS_fn_vSetIdentityMatrix( hAbsoluteMatrix );
|
|
POS_fn_vSetTranslationVector( hAbsoluteMatrix, &stVertexLocation );
|
|
GetInterface()->fn_vComputeNewRelativeMatrix (GetSuperObject()->GetStruct());
|
|
|
|
Link* poLink;
|
|
POSITION xPos;
|
|
|
|
for ( poLink=m_LinkList.GetHeadElement(xPos); poLink; poLink=m_LinkList.GetNextElement(xPos) )
|
|
GetInterface()->fn_vComputeRelativeMatrix (poLink->GetSuperObject(),GetSuperObject());
|
|
}
|
|
|
|
|
|
void Way::fn_vDialogAddWp (void)
|
|
{
|
|
if (m_lMode != c_Way_Add) return;
|
|
WayPoint* poLastWp = m_WaypointList.GetTail ();
|
|
if(m_pLinkBefore->fn_bIsWaypoint (poLastWp)) return;
|
|
fn_vStopModeAdd ();
|
|
fn_vModeAdd ();
|
|
}
|
|
|
|
void Way::fn_vDialogDeleteWp (void)
|
|
{
|
|
if (m_lMode != c_Way_Add) return;
|
|
if (m_WaypointList.GetCount()==0)
|
|
{
|
|
fn_vStopModeAdd ();
|
|
return;
|
|
}
|
|
WayPoint* poLastWp = m_WaypointList.GetTail ();
|
|
if (m_pLinkBefore->fn_bIsWaypoint (poLastWp)) return;
|
|
fn_vStopModeAdd ();
|
|
fn_vModeAdd ();
|
|
}
|
|
|
|
*/
|
|
//ENDANNECY Shaitan Nettoyage }
|