341 lines
9.8 KiB
C++
341 lines
9.8 KiB
C++
/*=========================================================================
|
|
*
|
|
* CPASObj.cpp - CPA_SuperObject : implementation
|
|
*
|
|
*
|
|
* Version 1.0
|
|
* Creation date 20.06.97
|
|
* Revision date
|
|
*
|
|
* Shaitan
|
|
*=======================================================================*/
|
|
#include "stdafx.h"
|
|
|
|
#ifdef ACTIVE_EDITOR
|
|
|
|
#include "acp_base.h"
|
|
|
|
#include "itf/CPASObj.hpp"
|
|
|
|
#include "itf/CPAMWorl.hpp"
|
|
#include "itf/CPAInter.hpp"
|
|
#include "itf/CPAHieEd.hpp"
|
|
#include "itf/CoheMngr.hpp"
|
|
|
|
#include "x:\cpa\Main\inc\_editid.h"
|
|
|
|
#include "DPT.h"
|
|
|
|
//#################################################################################
|
|
// CPA_SuperObject
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
Static Init
|
|
=========================================================================*/
|
|
|
|
void CPA_SuperObject::fn_vInitLoadEditor()
|
|
{
|
|
CPA_EdMot<HIE_tdxHandleToSuperObject>::Init(HIE_fn_hCreateSuperObject,HIE_fn_vCopySuperObject,HIE_fn_vDestroySuperObject);
|
|
}
|
|
|
|
/*===========================================================================
|
|
Constructor
|
|
=========================================================================*/
|
|
CPA_SuperObject::CPA_SuperObject (CPA_EditorBase *pEditor, HIE_tdxHandleToSuperObject hEngineSO,
|
|
tdeSaveStatus eStatus, tdeTypeSO eTypeSO)
|
|
: m_p_oObject(NULL),
|
|
CPA_EdMot<HIE_tdxHandleToSuperObject>(hEngineSO),
|
|
CPA_SuperObjectBase(hEngineSO),
|
|
CPA_ModifiableObject(pEditor, C_szSuperObjectTypeName, eStatus)
|
|
{
|
|
// parameters
|
|
m_p_oObjectDLLInterface = NULL;
|
|
m_pSuperObjectOwner = NULL;
|
|
m_bEditProtected = FALSE;
|
|
m_bAxisDrawn = FALSE;
|
|
m_bCenterVisible = FALSE;
|
|
m_csModelName = "";
|
|
|
|
SetTypeSO(eTypeSO);
|
|
}
|
|
|
|
/*===========================================================================
|
|
New Constructor
|
|
=========================================================================*/
|
|
CPA_SuperObject::CPA_SuperObject (CPA_EditorBase *pEditor, tdeSaveStatus eStatus, tdeTypeSO eTypeSO)
|
|
: m_p_oObject(NULL),
|
|
CPA_EdMot<HIE_tdxHandleToSuperObject>(),
|
|
CPA_SuperObjectBase(),
|
|
CPA_ModifiableObject(pEditor, C_szSuperObjectTypeName, eStatus)
|
|
{
|
|
GEO_tdxHandleToMatrix hLocalMatrix;
|
|
|
|
// local matrix
|
|
hLocalMatrix = GEO_fn_hCreateMatrix();
|
|
POS_fn_vSetIdentityMatrix(hLocalMatrix);
|
|
HIE_fn_vSetSuperObjectMatrix(GetStruct(), hLocalMatrix);
|
|
|
|
// parameters
|
|
m_p_oObjectDLLInterface = NULL;
|
|
m_pSuperObjectOwner = NULL;
|
|
m_bEditProtected = FALSE;
|
|
m_bAxisDrawn = FALSE;
|
|
m_bCenterVisible = FALSE;
|
|
m_csModelName = "";
|
|
|
|
SetTypeSO(eTypeSO);
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
Copy-Constructor
|
|
=========================================================================*/
|
|
CPA_SuperObject::CPA_SuperObject (CPA_SuperObject &r_oSource)
|
|
:m_p_oObject(NULL),
|
|
CPA_EdMot<HIE_tdxHandleToSuperObject>(r_oSource),
|
|
CPA_ModifiableObject(r_oSource),
|
|
CPA_SuperObjectBase()
|
|
{
|
|
// local matrix
|
|
POS_tdxHandleToPosition hLocalMatrix = (POS_tdxHandleToPosition) malloc (sizeof (POS_tdstCompletePosition));
|
|
POS_fn_vSetIdentityMatrix(hLocalMatrix);
|
|
GEO_M_vCopyMatrix(hLocalMatrix, HIE_fn_hGetSuperObjectMatrix(r_oSource.GetStruct()));
|
|
HIE_fn_vSetSuperObjectMatrix(GetStruct(), hLocalMatrix);
|
|
// global matrix
|
|
GEO_M_vCopyMatrix(HIE_fn_hGetSuperObjectGlobalMatrix(GetStruct()), HIE_fn_hGetSuperObjectGlobalMatrix(r_oSource.GetStruct()));
|
|
// copy common parameters
|
|
m_p_oObjectDLLInterface = r_oSource.m_p_oObjectDLLInterface;
|
|
m_pSuperObjectOwner = r_oSource.m_pSuperObjectOwner;
|
|
m_bEditProtected = r_oSource.m_bEditProtected;
|
|
m_bAxisDrawn = r_oSource.m_bAxisDrawn;
|
|
m_bCenterVisible = r_oSource.m_bCenterVisible;
|
|
m_csModelName = r_oSource.m_csModelName;
|
|
SetTypeSO(r_oSource.GetTypeSO());
|
|
// init object
|
|
SetObject(r_oSource.m_p_oObject);
|
|
}
|
|
|
|
/*===========================================================================
|
|
Destructor
|
|
=========================================================================*/
|
|
CPA_SuperObject::~CPA_SuperObject(void)
|
|
{
|
|
CPA_SuperObjectBase *p_oSuperObject;
|
|
POSITION P;
|
|
|
|
for(p_oSuperObject = GetHeadElement(P); p_oSuperObject;
|
|
p_oSuperObject = GetNextElement(P))
|
|
{
|
|
delete ((CPA_SuperObject *) p_oSuperObject);
|
|
p_oSuperObject = NULL;
|
|
}
|
|
}
|
|
|
|
/*===========================================================================
|
|
Object & DLL
|
|
=========================================================================*/
|
|
|
|
long CPA_SuperObject::GetObjectType()
|
|
{
|
|
return ( (m_p_oObject) ? m_p_oObject->GetDataType() : GetDataType() );
|
|
}
|
|
//===========================================================================
|
|
|
|
void CPA_SuperObject::SetObject (CPA_BaseObject * p_oNewObject)
|
|
{
|
|
if (m_p_oObject != NULL)
|
|
{
|
|
// warn coherence manager
|
|
g_oCoherenceManager.m_fn_vRemoveALink(this, m_p_oObject);
|
|
// cancel old link
|
|
m_p_oObject = NULL;
|
|
m_p_oObjectDLLInterface = NULL;
|
|
HIE_fn_vSetSuperObjectObjectAndType(GetStruct(), NULL, HIE_C_ulSuperObject);
|
|
}
|
|
|
|
if (p_oNewObject != NULL)
|
|
{
|
|
// warn coherence manager
|
|
g_oCoherenceManager.m_fn_vAddALink(this, p_oNewObject);
|
|
// set new link
|
|
m_p_oObject = p_oNewObject;
|
|
m_p_oObjectDLLInterface = (CPA_ObjectDLLBase *) (p_oNewObject->GetEditor());
|
|
HIE_fn_vSetSuperObjectObjectAndType(GetStruct(), p_oNewObject->GetData(), p_oNewObject->GetDataType());
|
|
}
|
|
else
|
|
{
|
|
m_p_oObject = NULL;
|
|
m_p_oObjectDLLInterface = NULL;
|
|
HIE_fn_vSetSuperObjectObjectAndType(GetStruct(), NULL, HIE_C_ulSuperObject);
|
|
}
|
|
}
|
|
|
|
/*===========================================================================
|
|
Hierarchy Links
|
|
=========================================================================*/
|
|
|
|
CPA_SuperObject * CPA_SuperObject::GetSuperObjectFirstChild (void)
|
|
{
|
|
return ((CPA_SuperObject *) GetHeadElement());
|
|
}
|
|
//===========================================================================
|
|
|
|
CPA_SuperObject * CPA_SuperObject::GetSuperObjectLastChild (void)
|
|
{
|
|
return ((CPA_SuperObject *) GetTailElement());
|
|
}
|
|
//===========================================================================
|
|
|
|
CPA_SuperObject * CPA_SuperObject::GetSuperObjectNextChild (CPA_SuperObject *pChild)
|
|
{
|
|
return ((CPA_SuperObject *) GetNextElement(pChild));
|
|
}
|
|
//===========================================================================
|
|
|
|
CPA_SuperObject * CPA_SuperObject::GetSuperObjectPrevChild (CPA_SuperObject *pChild)
|
|
{
|
|
return ((CPA_SuperObject *) GetPrevElement(pChild));
|
|
}
|
|
//===========================================================================
|
|
|
|
CPA_SuperObject * CPA_SuperObject::GetSuperObjectFather (void)
|
|
{
|
|
return ((CPA_SuperObject *) GetParent());
|
|
}
|
|
//===========================================================================
|
|
|
|
void CPA_SuperObject::AddANewChild (CPA_SuperObject *pChild, BOOL bUpdateEngine, CPA_SuperObject *pNextBrother)
|
|
{
|
|
POSITION pos = NULL;
|
|
|
|
// find position
|
|
if (pNextBrother)
|
|
pos = Find(pNextBrother);
|
|
// insert at the right position
|
|
if (pos)
|
|
InsertBefore(pos, pChild, bUpdateEngine);
|
|
else
|
|
AddTail(pChild, bUpdateEngine);
|
|
|
|
// warn coherence manager
|
|
g_oCoherenceManager.m_fn_vAddALink(this, pChild);
|
|
}
|
|
//===========================================================================
|
|
|
|
void CPA_SuperObject::RemoveAChild (CPA_SuperObject *pChild, BOOL bUpdateEngine)
|
|
{
|
|
POSITION pos = NULL;
|
|
|
|
// isolate child
|
|
pos = Find(pChild);
|
|
if (pos)
|
|
RemoveAt(pos, bUpdateEngine);
|
|
|
|
// warn coherence manager
|
|
g_oCoherenceManager.m_fn_vRemoveALink(this, pChild);
|
|
|
|
}
|
|
//===========================================================================
|
|
|
|
void CPA_SuperObject::RemoveAllChilds (BOOL bUpdateEngine)
|
|
{
|
|
CPA_SuperObject *pChild;
|
|
|
|
// remove childs
|
|
while (GetCount())
|
|
{
|
|
// remove child
|
|
pChild = (CPA_SuperObject *) RemoveHead(bUpdateEngine);
|
|
// warn coherence manager
|
|
g_oCoherenceManager.m_fn_vRemoveALink(this, pChild);
|
|
}
|
|
}
|
|
//===========================================================================
|
|
|
|
void CPA_SuperObject::IsolateChild (BOOL bUpdateEngine)
|
|
{
|
|
CPA_SuperObject *pFather;
|
|
|
|
// save father
|
|
pFather = GetSuperObjectFather();
|
|
|
|
// Isolate Child
|
|
Isolate(bUpdateEngine);
|
|
// warn coherence manager
|
|
if (pFather)
|
|
g_oCoherenceManager.m_fn_vRemoveALink(pFather, this);
|
|
}
|
|
|
|
|
|
//===========================================================================
|
|
|
|
void CPA_SuperObject::fn_vUpdateValidity (BOOL bValid)
|
|
{
|
|
CPA_SuperObject *pChild;
|
|
|
|
// update super-object
|
|
if (bValid)
|
|
fn_bValidate();
|
|
else
|
|
fn_bUnValidate();
|
|
|
|
// update all childs
|
|
for (pChild = GetSuperObjectFirstChild(); pChild;
|
|
pChild = GetSuperObjectNextChild(pChild))
|
|
pChild->fn_vUpdateValidity(bValid);
|
|
}
|
|
|
|
/*===========================================================================
|
|
Parameters
|
|
*=========================================================================*/
|
|
BOOL CPA_SuperObject::SetTypeSO (tdeTypeSO eType)
|
|
{
|
|
//Evt_Editor *pEditor = (Evt_Editor *) GetEditor();
|
|
|
|
// check editor specification
|
|
//if (pEditor->GetSpecificEditor()->fn_bCanChangeTypeSO(this, eType))
|
|
m_eTypeSO = eType;
|
|
|
|
// check if type is coherent
|
|
return (m_eTypeSO == eType);
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
Name & Name to draw
|
|
*=========================================================================*/
|
|
CString CPA_SuperObject::GetRealTypeName (void)
|
|
{
|
|
return ( (m_p_oObject) ? m_p_oObject->GetType() : GetType() );
|
|
}
|
|
|
|
//===========================================================================
|
|
|
|
BOOL CPA_SuperObject::fn_bIsUnderObject (CPA_SuperObject *pEdObj)
|
|
{
|
|
CPA_SuperObject *pParent;
|
|
|
|
if (pEdObj == this)
|
|
return TRUE;
|
|
|
|
pParent = GetSuperObjectFather();
|
|
if (!pParent)
|
|
return FALSE;
|
|
else
|
|
return (pParent->fn_bIsUnderObject(pEdObj));
|
|
}
|
|
|
|
//===========================================================================
|
|
|
|
void CPA_SuperObject::SetSuperObjectStruct (HIE_tdxHandleToSuperObject hSupObj)
|
|
{
|
|
// update base object
|
|
fn_vUpdateData(hSupObj);
|
|
// set engine struct
|
|
CPA_SuperObjectBase::SetSuperObjectStruct(hSupObj);
|
|
}
|
|
|
|
|
|
#endif // ACTIVE_EDITOR
|