//========================================================================
// EQUINOX-3D
//
// AUTHOR:  Gabor Nagy
// DATE:    2024-Oct-10 23:52:26
//
// Copyright (C) 1996-2026 By Gabor Nagy. All rights reserved.
//========================================================================
#ifndef _E3DP_CreateMacros_h
#define _E3DP_CreateMacros_h


#ifndef _E3D_Select_h
#include <E3D/Select.h>
#endif


#if defined (__cplusplus) && (!(defined (__CPLUSLIBS)))

extern "C" {
#endif


//================================================================================
// Activation callback template for a Geometry with construction-history
//================================================================================
#define E3dTpl_ObjectComponentActivateCB_Geometry(pObjectComponentClass) do\
{\
	E3dObject*  lObject = NULL;\
\
	E3dScene*  lScene = E3d_Scene;\
	E3dModel*  lModel = E3dModel_CustomObjectNew(lScene, (E3dObjectComponentClass*)(pObjectComponentClass), &lObject, (E3dp_Prefs.Duplicate_Flags & E3dCopyMODEL_UNIQUE_NAME) != 0);if(lModel)\
	{\
		E3dGeometry*  lGeometry = (E3dGeometry*)lObject;\
\
		lGeometry->AutoLOD = FALSE;\
\
		E3dScene_NodeHrcAdd(lScene, (E3dNode*)lModel, E3dCallSCENE_CALLBACKS);\
\
		E3dScene_ObjectsUpdateModelList(lScene);E3dScene_LayoutOnSchematics(lScene, TRUE);\
\
		EChangeFlags  lChanged = E3dChgHIERARCHY|E3dChgSCHEMATICS;\
\
		if(E3dp_Prefs.SelectNewModels)\
		{\
			E3dSel_NodeSelectTree(lScene, (E3dNode*)lModel, TRUE, TRUE);\
			E3dTransformPanel_Update(NULL, E3dDoALL, E3dDoALL, E3dDoALL,  E3dpDO_NOT_CHANGE,  E3dTrPanelALL);\
		}\
\
		if(lObject)\
		{\
			if(((XePushButtonCallbackStruct*)PCallData)->Reason == XeCR_ACTIVATE_OPTIONS) E3dObject_Edit(lObject, (pObjectComponentClass));\
			lChanged |= E3dObject_GetChangeFlagsByClass(lObject);\
		}\
\
		E3dWindows_RedrawByChangeFlags(lScene, lChanged);\
	}\
} while(0)

#if defined (__cplusplus) && (!(defined (__CPLUSLIBS)))
}	// Close scope of 'extern "C"' declaration
#endif

#endif	// _E3DP_CreateMacros_h
