860 lines
35 KiB
C++
860 lines
35 KiB
C++
/**
|
||
@file SelectionSetManager.h
|
||
|
||
Selection Sets related functions.
|
||
Selection sets are managed (creation from selection, deletion, on cmo load, on cmo save,
|
||
final data deletion,init, deinit)
|
||
through the CUIK3dEditor and tools function here
|
||
Selection sets can be created & managed with the LevelManager
|
||
(creation,deletion,add/remove object in/from)
|
||
|
||
@COPYRIGHT
|
||
|
||
@author Thomas Vissieres
|
||
*/
|
||
|
||
|
||
#if !defined(_SelectionSetManager_h_)
|
||
#define _SelectionSetManager_h_
|
||
|
||
//uncomment this to enable replace & share in addtion to "ignore & reload"
|
||
//#define ENABLE_REPLACE_AND_SHARE
|
||
|
||
//#endif
|
||
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
// includes
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
|
||
#include "set_enums.h"
|
||
#include "CKBaseManager.h"
|
||
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
//defines
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
|
||
#define USE_VERSIONCONTROL //will work only if interface is present
|
||
//#define SELECTIONSET_USE_DEPENDENCIES //disabled, because useless with ck2::Save
|
||
|
||
//VERSION HISTORY:
|
||
// 0 : beta
|
||
// 1 : 03/06/2006 - sp2,sp3 included
|
||
// 2 : 10/10/2007 - removal of dependencies
|
||
#define SELECTIONSETMANAGER_SAVEVERSION 2
|
||
#define SELECTIONSETMANAGER_CHUNK_VERSIONIDENTIFIER 0x0654f98aa
|
||
#define SELECTIONSETMANAGER_CHUNK_SAVEIDENTIFIER 0x0654f98ab
|
||
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
// guids
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
|
||
#define SELECTIONSETMANAGER_GUID CKGUID(0x4a6c44be,0x11845beb) //manager guid
|
||
#define CKPGUID_SETENUM CKGUID(0x0654f98ab,0x0654f98ac) //enum guid (use global/external/internal)
|
||
#define LOADSAVEGUID_SELECTIONSETDATA CKGUID(0x5d567df5,0x46ce6370) //interfaceobjectmanager data guid
|
||
|
||
|
||
|
||
|
||
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
// SelectionSet classes
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
|
||
class SelectionSetManager;
|
||
|
||
//generic macro to get selection manager from other projects
|
||
#define GetSelectionSetManagerMacro(context) ((SelectionSetManager*)context->GetManagerByGuid(SELECTIONSETMANAGER_GUID))
|
||
#define GetSelectionSetManagerMacro2(context) SelectionSetManager* SelSetMgr=(SelectionSetManager*)context->GetManagerByGuid(SELECTIONSETMANAGER_GUID)
|
||
|
||
namespace VirtoolsExternalPlugin
|
||
{
|
||
struct VersionControlInfo;
|
||
}
|
||
|
||
typedef VirtoolsExternalPlugin::VersionControlInfo VCI;
|
||
typedef XArray<CKGroup*> SelectionSetArray;
|
||
typedef SelectionSetArray::Iterator SelectionSetIT;
|
||
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
// selection set part than can be edited, related to interface
|
||
// this is used as notification code to tell interface what has been changed
|
||
// through CUIK_NOTIFICATION_SELECTIONSETS_MODIFIED notification
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
|
||
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
// SelectionSet Manager
|
||
// Manages Selection Sets
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
|
||
#ifndef LUA_SPECIFIC
|
||
|
||
class SELECTIONSETMANAGER_CLASS_DECL SelectionSetManager : public CKBaseManager
|
||
{
|
||
friend struct SelectionSetData;
|
||
public:
|
||
//constructor
|
||
SelectionSetManager(CKContext* Context);
|
||
~SelectionSetManager();
|
||
|
||
enum FSetManagerFlags
|
||
{
|
||
fSetMgrFlags_SkipNextLoadSave=1, //skip because not loading/saving a cmo/vmo
|
||
fSetMgrFlags_NoWebDownloadCheck, //dont check for webdowload
|
||
fSetMgrFlags_LoadingSet, //loading a set, so dont take into account onsequenceadded there
|
||
};
|
||
SET_DECLARE_FLAGS(m_Flags);
|
||
|
||
virtual CKDWORD GetValidFunctionsMask() {
|
||
return CKMANAGER_FUNC_PreClearAll |
|
||
CKMANAGER_FUNC_OnCKEnd |
|
||
CKMANAGER_FUNC_OnCKInit |
|
||
CKMANAGER_FUNC_PreSave |
|
||
CKMANAGER_FUNC_PostSave |
|
||
//CKMANAGER_FUNC_PreLoad |
|
||
CKMANAGER_FUNC_PostLoad |
|
||
CKMANAGER_FUNC_PostClearAll |
|
||
CKMANAGER_FUNC_PostProcess |
|
||
CKMANAGER_FUNC_OnSequenceAddedToScene |
|
||
CKMANAGER_FUNC_OnSequenceToBeDeleted;
|
||
}
|
||
|
||
virtual CKERROR OnCKInit(); //init selection set (variable manager bind)
|
||
virtual CKERROR OnCKEnd(); //deinit selection set (variable manager bind)
|
||
virtual CKERROR PreClearAll();
|
||
virtual CKERROR PostProcess();
|
||
virtual CKERROR SequenceToBeDeleted(CK_ID *objids,int count);
|
||
virtual CKERROR SequenceAddedToScene(CKScene *scn,CK_ID *objids,int count);
|
||
virtual CKStateChunk* SaveData(CKFile* SavedFile);
|
||
virtual CKERROR LoadData(CKStateChunk *chunk,CKFile* LoadedFile);
|
||
|
||
//before called in cuik.cpp-CUIKWinApp::DoSave() presave callback
|
||
//now externalized & in ckmanager
|
||
virtual CKERROR PreSave();
|
||
//before called in cuik.cpp-CUIKWinApp::DoSave() postsave callback
|
||
//now externalized & in ckmanager
|
||
virtual CKERROR PostSave();
|
||
|
||
//virtual CKERROR PreLoad();
|
||
virtual CKERROR PostLoad();
|
||
virtual CKERROR PostClearAll();
|
||
|
||
//presave2: used for objects shared between set & composition, ie mesh belong to set, but not the 3d entity
|
||
//=> we must save the mesh in cmo even if set is external
|
||
CKERROR PreSave2(); //called in cuik.cpp-CUIKWinApp::DoSave() presave callback
|
||
|
||
|
||
//clear all selection sets' datas
|
||
virtual void ClearSelectionSetsDatas();
|
||
//check check out state of external set
|
||
virtual void CloseExternalFileSets();
|
||
|
||
//get selection set global option "IncludeSelection Set"
|
||
//possible values :
|
||
// eReferencesOriginalFiles,
|
||
// eIncludeOriginalFiles,
|
||
// eForceReferencesOriginalFiles,
|
||
// eForceIncludeOriginalFiles,
|
||
virtual int GetIncludeSelectionSetSaveOption();
|
||
virtual void SetIncludeSelectionSetSaveOption(int iOption);
|
||
virtual int GetIncludeSelectionSetSaveOptionDescCount();
|
||
virtual char* GetIncludeSelectionSetSaveOptionDesc(int i);
|
||
|
||
//get sets
|
||
virtual CKGroup* GetSelectionSetByName(char* iName); //get selection sets list, if sorted, highest priority first
|
||
virtual void GetSelectionSets(XArray<CKGroup*>& oSelectionSets,BOOL iSortedByPriority=FALSE); //get selection sets list, if sorted, highest priority first
|
||
virtual void GetSelectionSets(XArray<CK_ID>& oSelectionSets,BOOL iSortedByPriority=FALSE); //get selection sets list, if sorted, highest priority first
|
||
virtual int GetSelectionSetCount();
|
||
virtual CKGroup* GetSelectionSet(int iIndex);
|
||
|
||
//set creation
|
||
//iNotify => notify interface
|
||
//iLoaded : flag as loaded from the start
|
||
//path : nmo path
|
||
//array : objects to add to the created selection set
|
||
//create a selection set
|
||
virtual CKGroup* CreateSelectionSet(XObjectArray* iArray,XString* iName=0,XString* iPath=0,BOOL iNotify=TRUE,BOOL iLoaded=TRUE);
|
||
virtual CKGroup* CreateSelectionSet(CKObjectArray* iArray,XString* iName=0,XString* iPath=0,BOOL iNotify=TRUE,BOOL iLoaded=TRUE);
|
||
//create a selection set
|
||
//create a selection set
|
||
virtual CKGroup* CreateSelectionSet(XString* iName=0,XString* iPath=0,BOOL iNotify=TRUE,BOOL iLoaded=TRUE);
|
||
//create a selection set from an existing group
|
||
virtual CKGroup* CreateSelectionSet(CKGroup* iGrp,XString* iPath=0);
|
||
|
||
//set tools
|
||
virtual CKGroup* CheckIsSelectionSet(CKObject* iObj); //check if group is a selection set
|
||
virtual BOOL AddObjectsToSet(CKGroup* iGrp,XObjectArray* iArray); //add objects to a selection set
|
||
virtual BOOL AddObjectsToSet(CKGroup* iGrp,CKObjectArray* iArray); //add objects to a selection set
|
||
virtual BOOL ModifySetFlags(CKGroup* iGrp,DWORD iAdded,DWORD iRemoved); //modify selection set flags
|
||
virtual DWORD GetSetFlags(CKGroup* iGrp); //get selection set flags
|
||
|
||
//check & ask for a path if not available
|
||
virtual BOOL CheckAndAskSelectionSetPath(CKGroup* iGrp,BOOL iForceNewPath,XString* oCurrentPath=0);
|
||
virtual BOOL CheckAllSelectionSetPath();
|
||
|
||
//set path access
|
||
virtual BOOL GetSelectionSetPath(CKGroup* iGrp,XString& oPath); //get selection set path, returns TRUE if there is a data & path (even empty), false if not a set or no data attached to set
|
||
virtual BOOL GetSelectionSetShortPath(CKGroup* iGrp,XString& oPath); //get selection set short path, that is relative path to cmo if possible
|
||
virtual BOOL GetSelectionSetShortPath(CK_ID iGrpId,XString& oPath); //short means relative path, if available
|
||
virtual BOOL GetSelectionSetPath(CK_ID iGrpId,XString& oPath); //get selection set path
|
||
virtual BOOL SetSelectionSetPath(CKGroup* iGrp,XString& iPath); //set selection set path
|
||
virtual BOOL SetSelectionSetPath(CK_ID iGrpId,XString& iPath); //set selection set path
|
||
virtual BOOL SetSelectionSetPath(CKGroup* iGrp,const char* iPath); //set selection set path
|
||
virtual BOOL SetSelectionSetPath(CK_ID iGrpId,const char* iPath); //set selection set path
|
||
|
||
virtual BOOL GetSelectionSetPath(SelectionSetData* iData,XString& oPath);//get selection set path, returns TRUE if there is a data & path (even empty), false if not a set or no data attached to set
|
||
|
||
virtual BOOL CheckRelativePath(XString& ioPath,BOOL iCompress);
|
||
|
||
//set data
|
||
virtual SelectionSetData* CreateSelectionSetData(CKGroup* iGrp); //Gets or create if does not exists
|
||
virtual BOOL SetSelectionSetData(CKGroup* iGrp,SelectionSetData* iData);
|
||
virtual SelectionSetData* GetSelectionSetData(CKGroup* iGrp); //Gets the selection sets datas
|
||
virtual BOOL DeleteSelectionSetData(CKGroup* iGrp); //delete the selection set's datas
|
||
|
||
//EDIT
|
||
//get unique name, iName is input & output
|
||
//use this function to set a selection set name too
|
||
virtual BOOL GetUniqueSelectionSetName(CKGroup* iGrp,XString* ioName,BOOL iSetName=FALSE,BOOL iSendNotification=FALSE);
|
||
|
||
//use this function to set a selection set name
|
||
virtual BOOL SetSelectionSetName(CKGroup* iGrp,XString* ioName,BOOL iSendNotification)
|
||
{ return GetUniqueSelectionSetName(iGrp,ioName,TRUE,iSendNotification); }
|
||
|
||
#ifdef SELECTIONSET_USE_DEPENDENCIES
|
||
//edit dependencies, return value : return of domodal, -1 if error
|
||
CKERROR EditDependencies(const char* iDialogTitle,const char* iDepName,CKDependencies* iDep);
|
||
|
||
//edit save dependencies for a specific set
|
||
CKERROR EditSetSaveDependencies(XArray<CKGroup*> &iGrps);
|
||
|
||
//remove dependencies
|
||
CKERROR RemoveSetSaveDependencies(XArray<CKGroup*> &iGrps);
|
||
|
||
//-----Global dependencies edition-----
|
||
void EditReloadDependencies();
|
||
//void EditPreSaveDependencies();
|
||
void EditSaveSetDependencies();
|
||
|
||
//tool function to save a dependency in a chunk
|
||
void SaveDependenciesInChunk(CKDependencies* iDep,CKStateChunk* iChunk);
|
||
//tool function to load a dependency from a chunk
|
||
void LoadDependenciesFromChunk(CKDependencies* iDep,CKStateChunk* iChunk);
|
||
#endif
|
||
|
||
|
||
//field : combination of FSetPart flags
|
||
virtual CKERROR SetField(XArray<CKGroup*> &iGrps,ESetFieldChange iChange,SelectionSetData::FSetFlags iDataFlags,BOOL iNotify,FSetPart iViewFlags);
|
||
|
||
//toggle rebuildhierarchy (0=>FALSE,1=>TRUE, other=>toggle
|
||
virtual CKERROR SetRebuildHierarchy(XArray<CKGroup*> &iGrps,ESetFieldChange iChange);
|
||
|
||
//toggle load with cmo (0=>FALSE,1=>TRUE, other=>toggle
|
||
virtual CKERROR SetLoadWithCmo(XArray<CKGroup*> &iGrps,ESetFieldChange iChange);
|
||
|
||
//toggle save with cmo (0=>FALSE,1=>TRUE, other=>toggle
|
||
virtual CKERROR SetSaveWithCmo(XArray<CKGroup*> &iGrps,ESetFieldChange iChange);
|
||
|
||
//toggle loadmode (0=>FALSE,1=>TRUE, other=>toggle
|
||
virtual CKERROR SetLoadMode(XArray<CKGroup*> &iGrps,ESetFieldChange iChange);
|
||
|
||
//edit selection set flags
|
||
//works only if Virtools Interface is present
|
||
virtual CKERROR EditSetFlags(XArray<CKGroup*> &iGrps);
|
||
|
||
//edit set priority
|
||
//works only if Virtools Interface is present
|
||
virtual CKERROR EditSetPriority(XArray<CKGroup*> &iGrps);
|
||
|
||
//edit set path (only available interface func in manager, using win32 = won't work on other system)
|
||
virtual CKERROR EditSetPath(CKGroup* iGrp);
|
||
|
||
//remove path
|
||
virtual CKERROR RemoveSetPath(XArray<CKGroup*> &iGrps);
|
||
|
||
//change set priority
|
||
virtual CKERROR SetSetPriority(XArray<CKGroup*> &iGrps,int iPriority);
|
||
|
||
//compact set, ie keep only top object that references (by dependencies) other objects
|
||
virtual BOOL CompactSets(XArray<CKGroup*> &iGrps);
|
||
|
||
//Save & load in cmo : iFromCMO true means this function is called while loading/saving a cmo.
|
||
// Should be by default, but option is available just in case
|
||
virtual BOOL LoadSelectionSetFromChunk(CKStateChunk* iChunk,BOOL iFromCMO); //called from 3d editor in loaddata (saved in cmo)
|
||
//loads all selset, internal as well as external
|
||
virtual BOOL SaveSelectionSetInChunk(CKStateChunk* iChunk,BOOL iFromCMO,XArray<CKGroup*>* iSets=0); //called from 3d editor in savedata (saved in cmo)
|
||
//save only internal set,& check external sets' paths
|
||
//external will be saved from cuik.cpp:dosave
|
||
|
||
//load hierarchy to rebuild from chunk
|
||
virtual BOOL LoadRebuildHierarchyFromChunk(CKGroup* iGrp,CKStateChunk* iChunk);
|
||
//save hierarchy to rebuild in chunk
|
||
virtual BOOL SaveRebuildHierarchyFromChunk(CKGroup* iGrp,CKStateChunk* iChunk);
|
||
|
||
//save & load set
|
||
//save selection set, iForceNewPath <=> open a dialog to choose path
|
||
virtual BOOL SaveSelectionSet(CKGroup* iGrp,BOOL iForceNewPath,XString* oErrorLog=0);
|
||
|
||
virtual CKERROR SaveGroup(CKGroup* iGrp,const char* iPath,CKDependencies* iDep,CKObjectArray* iToAppend);
|
||
|
||
//load selection set
|
||
//iUserManualReload=> used only when called outside the manager
|
||
//and when the nmo does not contains a parent group (meaning, it was not a selection set before, which is bad)
|
||
//if this bool=TRUE, then the func will notify the interface about that
|
||
//return value :
|
||
// 0 => set not found
|
||
// 0xffffffff => loading on the web, use GetLastWebDownloadSetHandle() to retrieve handle
|
||
//virtual CKGroup* LoadSelectionSet(CKGroup* iGrp,SelectionSetData* iData=0,BOOL iDynamic=FALSE,XString* oErrorLog=0,BOOL iUserManualReload=FALSE);
|
||
virtual ESetLoadResult LoadSelectionSet(CKGroup*& ioGrp,BOOL iDynamic=FALSE,BOOL iUserManualReload=FALSE,XString* oErrorLog=0);
|
||
virtual ESetLoadResult LoadSelectionSet(CKGroup*& ioGrp,SelectionSetData* iData,BOOL iDynamic=FALSE,BOOL iUserManualReload=FALSE,XString* oErrorLog=0);
|
||
|
||
//reload sel set
|
||
//BOOL ReloadSelectionSet(CKGroup* iGrp,BOOL iUserManualReload,XString* oErrorLog=0);
|
||
|
||
//unload set
|
||
virtual BOOL UnloadSets(XArray<CKGroup*> &iGrps,BOOL iDeleteGroup=FALSE);
|
||
|
||
|
||
//get last saved set
|
||
virtual CKGroup* GetLastSavedSet();
|
||
virtual CK_ID GetLastSavedSetID() {return m_LastSavedSetID;}
|
||
//Save last saved set
|
||
virtual BOOL SaveLastSavedSet();
|
||
|
||
//misc tools
|
||
static void CKGroupToCKIDArray(XArray<CKGroup*>* iObjects,XArray<CK_ID>* oIDs);
|
||
|
||
//for vsl bind
|
||
static SelectionSetManager* Cast(CKBaseManager* iM)
|
||
{
|
||
return (SelectionSetManager*)iM;
|
||
}
|
||
|
||
|
||
//vsl bind
|
||
CKERROR SelectionSetManager::Bind();
|
||
CKERROR SelectionSetManager::UnBind();
|
||
|
||
/********
|
||
DATAS
|
||
********/
|
||
public:
|
||
enum FSetFlags
|
||
{
|
||
eReferencesOriginalFiles,
|
||
eIncludeOriginalFiles,
|
||
eForceReferencesOriginalFiles,
|
||
eForceIncludeOriginalFiles,
|
||
eSelectionSetFlagsCount,
|
||
};
|
||
|
||
/* -----SelectionSetParameter----- */
|
||
void RegisterSelectionSetParameter(CKParameter* iParam);
|
||
void UnRegisterSelectionSetParameter(CK_ID iID);
|
||
|
||
/* -----SelectionSet download from web----- */
|
||
//return value : handle for the last currently loading set
|
||
//-1 if none
|
||
int GetLastWebDownloadSetHandle();
|
||
|
||
//called by BBs
|
||
ESetLoadResult GetWebDownloadSetState(int webHandle,CKGroup*& oSet);
|
||
//called by post process
|
||
void WebDownloadSet();
|
||
|
||
private:
|
||
/* -----SelectionSet download from web----- */
|
||
struct WebSet
|
||
{
|
||
CKGroup* grp;
|
||
SelectionSetData* data;
|
||
int webHandle; //WebHandle
|
||
BOOL dyn;
|
||
BOOL manual;
|
||
ESetLoadResult state;
|
||
};
|
||
XClassArray<WebSet> m_WebDownloadSets;
|
||
|
||
|
||
/* -----SelectionSetParameter----- */
|
||
void RemapSelectionSetParameters(CKGroup* iGrp,BOOL iCreated);
|
||
void SaveSelectionSetParameters(CKStateChunk* iChunk);
|
||
void LoadSelectionSetParameters(CKStateChunk* iChunk);
|
||
XArray<CK_ID> m_params2remap;
|
||
XArray<CK_ID> m_SelectionSetParams;
|
||
|
||
/* -----Preferences----- */
|
||
|
||
//if true, then save selection set internally to cmo, otherwise externally (for useGlobalOptions sets)
|
||
int m_IncludeSelectionSetSaveOption;
|
||
|
||
//save external selection sets on cmo save
|
||
int m_SaveExternalSetsOnCmoSave;
|
||
|
||
//save .bak / backup when saving sets
|
||
int m_BackupOnSaveSet;
|
||
|
||
//compact set on load
|
||
BOOL m_CompactSetOnLoad;
|
||
|
||
/* -----arrays to store objects no to save while saving cmos----- */
|
||
XObjectArray m_NotToSaveObjectList;
|
||
|
||
/* -----Global dependencies----- */
|
||
|
||
//note m_PreSaveCmoDependencies & m_SaveSetDependencies sont cens<6E> etre les memes
|
||
//CKDependencies m_ReloadSetDependencies; //for deletion of objects that are no more in the reloaded set
|
||
//CKDependencies m_PreSaveCmoDependencies;//to flag external selection set's objects "not to be saved"
|
||
CKDependencies m_SaveSetDependencies;//when saving a set
|
||
|
||
//last saved set
|
||
CK_ID m_LastSavedSetID;
|
||
|
||
//last version read from chunk
|
||
int m_Version;
|
||
|
||
//load mode ?
|
||
enum ELoadingMode{
|
||
eUseLastLoadedCMO,
|
||
eUseLastSavedCMO,
|
||
ePostClearAll,
|
||
eUseParam,
|
||
};
|
||
|
||
//last dir to use with sets
|
||
XString m_LastDir;
|
||
XString m_LastFile;
|
||
//return TRUE : ok
|
||
//return FALSE : skip next load/save because it is related to something other than cmo/vmo
|
||
BOOL UpdateLastDir(ELoadingMode iMode,CKSTRING iFilename=0);
|
||
|
||
//version control
|
||
VCI* m_VCI;
|
||
|
||
//chunk backup from loaddata for postload because:
|
||
//loading file
|
||
// =>loading objects
|
||
// manager::loaddata
|
||
// scene::load
|
||
// remove all objects from scene
|
||
// reload all scene objects from chunk
|
||
// => thus all created objects in ::LoadData are lost
|
||
// need to backup the chunk from :LoadData
|
||
CKStateChunk* m_LoadChunk;
|
||
};
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
#else //#ifdef SELECTIONSETMANAGER_EXPORTS
|
||
|
||
class SELECTIONSETMANAGER_CLASS_DECL SelectionSetManager : public CKBaseManager
|
||
{
|
||
friend struct SelectionSetData;
|
||
public:
|
||
//constructor
|
||
SelectionSetManager(CKContext* Context);
|
||
~SelectionSetManager();
|
||
|
||
enum FSetManagerFlags
|
||
{
|
||
fSetMgrFlags_SkipNextLoadSave=1, //skip because not loading/saving a cmo/vmo
|
||
fSetMgrFlags_NoWebDownloadCheck, //dont check for webdowload
|
||
fSetMgrFlags_LoadingSet, //loading a set, so dont take into account onsequenceadded there
|
||
};
|
||
SET_DECLARE_FLAGS(m_Flags);
|
||
|
||
virtual CKDWORD GetValidFunctionsMask() {
|
||
return CKMANAGER_FUNC_PreClearAll |
|
||
CKMANAGER_FUNC_OnCKEnd |
|
||
CKMANAGER_FUNC_OnCKInit |
|
||
CKMANAGER_FUNC_PreSave |
|
||
CKMANAGER_FUNC_PostSave |
|
||
//CKMANAGER_FUNC_PreLoad |
|
||
CKMANAGER_FUNC_PostLoad |
|
||
CKMANAGER_FUNC_PostClearAll |
|
||
CKMANAGER_FUNC_PostProcess |
|
||
CKMANAGER_FUNC_OnSequenceAddedToScene |
|
||
CKMANAGER_FUNC_OnSequenceToBeDeleted;
|
||
}
|
||
|
||
virtual CKERROR OnCKInit(); //init selection set (variable manager bind)
|
||
virtual CKERROR OnCKEnd(); //deinit selection set (variable manager bind)
|
||
virtual CKERROR PreClearAll();
|
||
virtual CKERROR PostProcess();
|
||
virtual CKERROR SequenceToBeDeleted(CK_ID *objids,int count);
|
||
virtual CKERROR SequenceAddedToScene(CKScene *scn,CK_ID *objids,int count);
|
||
virtual CKStateChunk* SaveData(CKFile* SavedFile);
|
||
virtual CKERROR LoadData(CKStateChunk *chunk,CKFile* LoadedFile);
|
||
|
||
//before called in cuik.cpp-CUIKWinApp::DoSave() presave callback
|
||
//now externalized & in ckmanager
|
||
virtual CKERROR PreSave();
|
||
//before called in cuik.cpp-CUIKWinApp::DoSave() postsave callback
|
||
//now externalized & in ckmanager
|
||
virtual CKERROR PostSave();
|
||
|
||
//virtual CKERROR PreLoad();
|
||
virtual CKERROR PostLoad();
|
||
virtual CKERROR PostClearAll();
|
||
|
||
//presave2: used for objects shared between set & composition, ie mesh belong to set, but not the 3d entity
|
||
//=> we must save the mesh in cmo even if set is external
|
||
CKERROR PreSave2(); //called in cuik.cpp-CUIKWinApp::DoSave() presave callback
|
||
|
||
|
||
//clear all selection sets' datas
|
||
virtual void ClearSelectionSetsDatas();
|
||
//check check out state of external set
|
||
virtual void CloseExternalFileSets();
|
||
|
||
//get selection set global option "IncludeSelection Set"
|
||
//possible values :
|
||
// eReferencesOriginalFiles,
|
||
// eIncludeOriginalFiles,
|
||
// eForceReferencesOriginalFiles,
|
||
// eForceIncludeOriginalFiles,
|
||
virtual int GetIncludeSelectionSetSaveOption();
|
||
virtual void SetIncludeSelectionSetSaveOption(int iOption);
|
||
virtual int GetIncludeSelectionSetSaveOptionDescCount();
|
||
virtual char* GetIncludeSelectionSetSaveOptionDesc(int i);
|
||
|
||
//get sets
|
||
virtual CKGroup* GetSelectionSetByName(char* iName); //get selection sets list, if sorted, highest priority first
|
||
virtual void GetSelectionSets(XArray<CKObject*>& oSelectionSets,BOOL iSortedByPriority=FALSE); //get selection sets list, if sorted, highest priority first
|
||
virtual void GetSelectionSets(XArray<CK_ID>& oSelectionSets,BOOL iSortedByPriority=FALSE); //get selection sets list, if sorted, highest priority first
|
||
virtual int GetSelectionSetCount();
|
||
virtual CKGroup* GetSelectionSet(int iIndex);
|
||
|
||
//set creation
|
||
//iNotify => notify interface
|
||
//iLoaded : flag as loaded from the start
|
||
//path : nmo path
|
||
//array : objects to add to the created selection set
|
||
//create a selection set
|
||
virtual CKGroup* CreateSelectionSet(XIntArray* iArray,XString* iName=0,XString* iPath=0,BOOL iNotify=TRUE,BOOL iLoaded=TRUE);
|
||
virtual CKGroup* CreateSelectionSet(CKObjectArray* iArray,XString* iName=0,XString* iPath=0,BOOL iNotify=TRUE,BOOL iLoaded=TRUE);
|
||
//create a selection set
|
||
//create a selection set
|
||
virtual CKGroup* CreateSelectionSet(XString* iName=0,XString* iPath=0,BOOL iNotify=TRUE,BOOL iLoaded=TRUE);
|
||
//create a selection set from an existing group
|
||
virtual CKGroup* CreateSelectionSet(CKGroup* iGrp,XString* iPath=0);
|
||
|
||
//set tools
|
||
virtual CKGroup* CheckIsSelectionSet(CKObject* iObj); //check if group is a selection set
|
||
virtual BOOL AddObjectsToSet(CKGroup* iGrp,XIntArray* iArray); //add objects to a selection set
|
||
virtual BOOL AddObjectsToSet(CKGroup* iGrp,CKObjectArray* iArray); //add objects to a selection set
|
||
virtual BOOL ModifySetFlags(CKGroup* iGrp,DWORD iAdded,DWORD iRemoved); //modify selection set flags
|
||
virtual DWORD GetSetFlags(CKGroup* iGrp); //get selection set flags
|
||
|
||
//check & ask for a path if not available
|
||
virtual BOOL CheckAndAskSelectionSetPath(CKGroup* iGrp,BOOL iForceNewPath,XString* oCurrentPath=0);
|
||
virtual BOOL CheckAllSelectionSetPath();
|
||
|
||
//set path access
|
||
virtual BOOL GetSelectionSetPath(CKGroup* iGrp,XString& oPath); //get selection set path, returns TRUE if there is a data & path (even empty), false if not a set or no data attached to set
|
||
virtual BOOL GetSelectionSetShortPath(CKGroup* iGrp,XString& oPath); //get selection set short path, that is relative path to cmo if possible
|
||
virtual BOOL GetSelectionSetShortPath(CK_ID iGrpId,XString& oPath); //short means relative path, if available
|
||
virtual BOOL GetSelectionSetPath(CK_ID iGrpId,XString& oPath); //get selection set path
|
||
virtual BOOL SetSelectionSetPath(CKGroup* iGrp,XString& iPath); //set selection set path
|
||
virtual BOOL SetSelectionSetPath(CK_ID iGrpId,XString& iPath); //set selection set path
|
||
virtual BOOL SetSelectionSetPath(CKGroup* iGrp,const char* iPath); //set selection set path
|
||
virtual BOOL SetSelectionSetPath(CK_ID iGrpId,const char* iPath); //set selection set path
|
||
|
||
virtual BOOL GetSelectionSetPath(SelectionSetData* iData,XString& oPath);//get selection set path, returns TRUE if there is a data & path (even empty), false if not a set or no data attached to set
|
||
|
||
virtual BOOL CheckRelativePath(XString& ioPath,BOOL iCompress);
|
||
|
||
//set data
|
||
virtual SelectionSetData* CreateSelectionSetData(CKGroup* iGrp); //Gets or create if does not exists
|
||
virtual BOOL SetSelectionSetData(CKGroup* iGrp,SelectionSetData* iData);
|
||
virtual SelectionSetData* GetSelectionSetData(CKGroup* iGrp); //Gets the selection sets datas
|
||
virtual BOOL DeleteSelectionSetData(CKGroup* iGrp); //delete the selection set's datas
|
||
|
||
//EDIT
|
||
//get unique name, iName is input & output
|
||
//use this function to set a selection set name too
|
||
virtual BOOL GetUniqueSelectionSetName(CKGroup* iGrp,XString* ioName,BOOL iSetName=FALSE,BOOL iSendNotification=FALSE);
|
||
|
||
//use this function to set a selection set name
|
||
virtual BOOL SetSelectionSetName(CKGroup* iGrp,XString* ioName,BOOL iSendNotification)
|
||
{ return GetUniqueSelectionSetName(iGrp,ioName,TRUE,iSendNotification); }
|
||
|
||
#ifdef SELECTIONSET_USE_DEPENDENCIES
|
||
//edit dependencies, return value : return of domodal, -1 if error
|
||
CKERROR EditDependencies(const char* iDialogTitle,const char* iDepName,CKDependencies* iDep);
|
||
|
||
//edit save dependencies for a specific set
|
||
CKERROR EditSetSaveDependencies(XArray<CKObject*> &iGrps);
|
||
|
||
//remove dependencies
|
||
CKERROR RemoveSetSaveDependencies(XArray<CKObject*> &iGrps);
|
||
|
||
//-----Global dependencies edition-----
|
||
void EditReloadDependencies();
|
||
//void EditPreSaveDependencies();
|
||
void EditSaveSetDependencies();
|
||
|
||
//tool function to save a dependency in a chunk
|
||
void SaveDependenciesInChunk(CKDependencies* iDep,CKStateChunk* iChunk);
|
||
//tool function to load a dependency from a chunk
|
||
void LoadDependenciesFromChunk(CKDependencies* iDep,CKStateChunk* iChunk);
|
||
#endif
|
||
|
||
|
||
//field : combination of FSetPart flags
|
||
virtual CKERROR SetField(XArray<CKObject*> &iGrps,ESetFieldChange iChange,FSetFlags iDataFlags,BOOL iNotify,FSetPart iViewFlags);
|
||
|
||
//toggle rebuildhierarchy (0=>FALSE,1=>TRUE, other=>toggle
|
||
virtual CKERROR SetRebuildHierarchy(XArray<CKObject*> &iGrps,ESetFieldChange iChange);
|
||
|
||
//toggle load with cmo (0=>FALSE,1=>TRUE, other=>toggle
|
||
virtual CKERROR SetLoadWithCmo(XArray<CKObject*> &iGrps,ESetFieldChange iChange);
|
||
|
||
//toggle save with cmo (0=>FALSE,1=>TRUE, other=>toggle
|
||
virtual CKERROR SetSaveWithCmo(XArray<CKObject*> &iGrps,ESetFieldChange iChange);
|
||
|
||
//toggle loadmode (0=>FALSE,1=>TRUE, other=>toggle
|
||
virtual CKERROR SetLoadMode(XArray<CKObject*> &iGrps,ESetFieldChange iChange);
|
||
|
||
//edit selection set flags
|
||
//works only if Virtools Interface is present
|
||
virtual CKERROR EditSetFlags(XArray<CKObject*> &iGrps);
|
||
|
||
//edit set priority
|
||
//works only if Virtools Interface is present
|
||
virtual CKERROR EditSetPriority(XArray<CKObject*> &iGrps);
|
||
|
||
//edit set path (only available interface func in manager, using win32 = won't work on other system)
|
||
virtual CKERROR EditSetPath(CKGroup* iGrp);
|
||
|
||
//remove path
|
||
virtual CKERROR RemoveSetPath(XArray<CKObject*> &iGrps);
|
||
|
||
//change set priority
|
||
virtual CKERROR SetSetPriority(XArray<CKObject*> &iGrps,int iPriority);
|
||
|
||
//compact set, ie keep only top object that references (by dependencies) other objects
|
||
virtual BOOL CompactSets(XArray<CKObject*> &iGrps);
|
||
|
||
//Save & load in cmo : iFromCMO true means this function is called while loading/saving a cmo.
|
||
// Should be by default, but option is available just in case
|
||
virtual BOOL LoadSelectionSetFromChunk(CKStateChunk* iChunk,BOOL iFromCMO); //called from 3d editor in loaddata (saved in cmo)
|
||
//loads all selset, internal as well as external
|
||
virtual BOOL SaveSelectionSetInChunk(CKStateChunk* iChunk,BOOL iFromCMO,XArray<CKObject*>* iSets=0); //called from 3d editor in savedata (saved in cmo)
|
||
//save only internal set,& check external sets' paths
|
||
//external will be saved from cuik.cpp:dosave
|
||
|
||
//load hierarchy to rebuild from chunk
|
||
virtual BOOL LoadRebuildHierarchyFromChunk(CKGroup* iGrp,CKStateChunk* iChunk);
|
||
//save hierarchy to rebuild in chunk
|
||
virtual BOOL SaveRebuildHierarchyFromChunk(CKGroup* iGrp,CKStateChunk* iChunk);
|
||
|
||
//save & load set
|
||
//save selection set, iForceNewPath <=> open a dialog to choose path
|
||
virtual BOOL SaveSelectionSet(CKGroup* iGrp,BOOL iForceNewPath=FALSE,XString* oErrorLog=0);
|
||
|
||
virtual CKERROR SaveGroup(CKGroup* iGrp,const char* iPath,CKDependencies* iDep,CKObjectArray* iToAppend);
|
||
|
||
//load selection set
|
||
//iUserManualReload=> used only when called outside the manager
|
||
//and when the nmo does not contains a parent group (meaning, it was not a selection set before, which is bad)
|
||
//if this bool=TRUE, then the func will notify the interface about that
|
||
//return value :
|
||
// 0 => set not found
|
||
// 0xffffffff => loading on the web, use GetLastWebDownloadSetHandle() to retrieve handle
|
||
//virtual CKGroup* LoadSelectionSet(CKGroup* iGrp,SelectionSetData* iData=0,BOOL iDynamic=FALSE,XString* oErrorLog=0,BOOL iUserManualReload=FALSE);
|
||
virtual ESetLoadResult LoadSelectionSet(CKGroup*& ioGrp,BOOL iDynamic=FALSE,BOOL iUserManualReload=FALSE,XString* oErrorLog=0);
|
||
virtual ESetLoadResult LoadSelectionSet(CKGroup*& ioGrp,SelectionSetData* iData,BOOL iDynamic=FALSE,BOOL iUserManualReload=FALSE,XString* oErrorLog=0);
|
||
|
||
//reload sel set
|
||
//BOOL ReloadSelectionSet(CKGroup* iGrp,BOOL iUserManualReload,XString* oErrorLog=0);
|
||
|
||
//unload set
|
||
virtual BOOL UnloadSets(XArray<CKObject*> &iGrps,BOOL iDeleteGroup=FALSE);
|
||
|
||
|
||
//get last saved set
|
||
virtual CKGroup* GetLastSavedSet();
|
||
virtual CK_ID GetLastSavedSetID() {return m_LastSavedSetID;}
|
||
//Save last saved set
|
||
virtual BOOL SaveLastSavedSet();
|
||
|
||
//misc tools
|
||
static void CKGroupToCKIDArray(XArray<CKObject*>* iObjects,XArray<CK_ID>* oIDs);
|
||
|
||
//for vsl bind
|
||
static SelectionSetManager* Cast(CKBaseManager* iM)
|
||
{
|
||
return (SelectionSetManager*)iM;
|
||
}
|
||
|
||
|
||
//vsl bind
|
||
CKERROR SelectionSetManager::Bind();
|
||
CKERROR SelectionSetManager::UnBind();
|
||
|
||
/********
|
||
DATAS
|
||
********/
|
||
public:
|
||
enum FSetMgrFlags
|
||
{
|
||
eReferencesOriginalFiles,
|
||
eIncludeOriginalFiles,
|
||
eForceReferencesOriginalFiles,
|
||
eForceIncludeOriginalFiles,
|
||
eSelectionSetFlagsCount,
|
||
};
|
||
|
||
/* -----SelectionSetParameter----- */
|
||
void RegisterSelectionSetParameter(CKParameter* iParam);
|
||
void UnRegisterSelectionSetParameter(CK_ID iID);
|
||
|
||
/* -----SelectionSet download from web----- */
|
||
//return value : handle for the last currently loading set
|
||
//-1 if none
|
||
int GetLastWebDownloadSetHandle();
|
||
|
||
//called by BBs
|
||
ESetLoadResult GetWebDownloadSetState(int webHandle,CKGroup*& oSet);
|
||
//called by post process
|
||
void WebDownloadSet();
|
||
|
||
private:
|
||
/* -----SelectionSet download from web----- */
|
||
struct WebSet
|
||
{
|
||
CKGroup* grp;
|
||
SelectionSetData* data;
|
||
int webHandle; //WebHandle
|
||
BOOL dyn;
|
||
BOOL manual;
|
||
ESetLoadResult state;
|
||
};
|
||
XClassArray<WebSet> m_WebDownloadSets;
|
||
|
||
|
||
/* -----SelectionSetParameter----- */
|
||
void RemapSelectionSetParameters(CKGroup* iGrp,BOOL iCreated);
|
||
void SaveSelectionSetParameters(CKStateChunk* iChunk);
|
||
void LoadSelectionSetParameters(CKStateChunk* iChunk);
|
||
XArray<CK_ID> m_params2remap;
|
||
XArray<CK_ID> m_SelectionSetParams;
|
||
|
||
/* -----Preferences----- */
|
||
|
||
//if true, then save selection set internally to cmo, otherwise externally (for useGlobalOptions sets)
|
||
int m_IncludeSelectionSetSaveOption;
|
||
|
||
//save external selection sets on cmo save
|
||
int m_SaveExternalSetsOnCmoSave;
|
||
|
||
//save .bak / backup when saving sets
|
||
int m_BackupOnSaveSet;
|
||
|
||
//compact set on load
|
||
BOOL m_CompactSetOnLoad;
|
||
|
||
/* -----arrays to store objects no to save while saving cmos----- */
|
||
XObjectArray m_NotToSaveObjectList;
|
||
|
||
/* -----Global dependencies----- */
|
||
|
||
//note m_PreSaveCmoDependencies & m_SaveSetDependencies sont cens<6E> etre les memes
|
||
//CKDependencies m_ReloadSetDependencies; //for deletion of objects that are no more in the reloaded set
|
||
//CKDependencies m_PreSaveCmoDependencies;//to flag external selection set's objects "not to be saved"
|
||
CKDependencies m_SaveSetDependencies;//when saving a set
|
||
|
||
//last saved set
|
||
CK_ID m_LastSavedSetID;
|
||
|
||
//last version read from chunk
|
||
int m_Version;
|
||
|
||
//load mode ?
|
||
enum ELoadingMode{
|
||
eUseLastLoadedCMO,
|
||
eUseLastSavedCMO,
|
||
ePostClearAll,
|
||
eUseParam,
|
||
};
|
||
|
||
//last dir to use with sets
|
||
XString m_LastDir;
|
||
XString m_LastFile;
|
||
//return TRUE : ok
|
||
//return FALSE : skip next load/save because it is related to something other than cmo/vmo
|
||
BOOL UpdateLastDir(ELoadingMode iMode,CKSTRING iFilename=0);
|
||
|
||
//version control
|
||
VCI* m_VCI;
|
||
|
||
//chunk backup from loaddata for postload because:
|
||
//loading file
|
||
// =>loading objects
|
||
// manager::loaddata
|
||
// scene::load
|
||
// remove all objects from scene
|
||
// reload all scene objects from chunk
|
||
// => thus all created objects in ::LoadData are lost
|
||
// need to backup the chunk from :LoadData
|
||
CKStateChunk* m_LoadChunk;
|
||
};
|
||
|
||
#endif //#ifdef SELECTIONSETMANAGER_EXPORTS
|
||
|
||
#endif // _SelectionSetManager_h
|