2002-10-12 11:37:38 +00:00
|
|
|
/*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-01-07 19:13:47 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
2012-02-17 18:59:41 +00:00
|
|
|
#ifndef __BLO_READFILE_H__
|
|
|
|
#define __BLO_READFILE_H__
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-02-17 23:34:07 +00:00
|
|
|
/** \file BLO_readfile.h
|
2011-02-27 20:35:41 +00:00
|
|
|
* \ingroup blenloader
|
2011-02-17 23:34:07 +00:00
|
|
|
* \brief external readfile function prototypes.
|
|
|
|
*/
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2008-12-19 00:50:21 +00:00
|
|
|
struct bScreen;
|
|
|
|
struct direntry;
|
2002-10-12 11:37:38 +00:00
|
|
|
struct LinkNode;
|
|
|
|
struct Main;
|
2004-09-05 13:43:51 +00:00
|
|
|
struct MemFile;
|
2008-12-19 00:50:21 +00:00
|
|
|
struct ReportList;
|
|
|
|
struct Scene;
|
|
|
|
struct SpaceFile;
|
|
|
|
struct UserDef;
|
2009-09-12 19:54:39 +00:00
|
|
|
struct bContext;
|
2011-05-18 19:42:30 +00:00
|
|
|
struct BHead;
|
|
|
|
struct FileData;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
typedef struct BlendHandle BlendHandle;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
typedef enum BlenFileType {
|
2012-05-12 20:39:39 +00:00
|
|
|
BLENFILETYPE_BLEND = 1,
|
|
|
|
BLENFILETYPE_PUB = 2,
|
|
|
|
BLENFILETYPE_RUNTIME = 3
|
2002-10-12 11:37:38 +00:00
|
|
|
} BlenFileType;
|
|
|
|
|
|
|
|
typedef struct BlendFileData {
|
2012-05-12 20:39:39 +00:00
|
|
|
struct Main *main;
|
|
|
|
struct UserDef *user;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
int winpos;
|
|
|
|
int fileflags;
|
|
|
|
int displaymode;
|
2003-07-21 19:41:07 +00:00
|
|
|
int globalf;
|
2012-05-12 20:39:39 +00:00
|
|
|
char filename[1024]; /* 1024 = FILE_MAX */
|
2007-12-24 18:53:37 +00:00
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
struct bScreen *curscreen;
|
|
|
|
struct Scene *curscene;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
BlenFileType type;
|
2002-10-12 11:37:38 +00:00
|
|
|
} BlendFileData;
|
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
/**
|
|
|
|
* Open a blender file from a pathname. The function
|
|
|
|
* returns NULL and sets a report in the list if
|
|
|
|
* it cannot open the file.
|
|
|
|
*
|
|
|
|
* \param filepath The path of the file to open.
|
|
|
|
* \param reports If the return value is NULL, errors
|
|
|
|
* indicating the cause of the failure.
|
|
|
|
* \return The data of the file.
|
|
|
|
*/
|
2014-02-01 00:51:53 +11:00
|
|
|
BlendFileData *BLO_read_from_file(
|
|
|
|
const char *filepath,
|
|
|
|
struct ReportList *reports);
|
2012-05-12 20:39:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Open a blender file from memory. The function
|
|
|
|
* returns NULL and sets a report in the list if
|
|
|
|
* it cannot open the file.
|
|
|
|
*
|
|
|
|
* \param mem The file data.
|
|
|
|
* \param memsize The length of \a mem.
|
|
|
|
* \param reports If the return value is NULL, errors
|
|
|
|
* indicating the cause of the failure.
|
|
|
|
* \return The data of the file.
|
|
|
|
*/
|
2014-02-01 00:51:53 +11:00
|
|
|
BlendFileData *BLO_read_from_memory(
|
|
|
|
const void *mem, int memsize,
|
|
|
|
struct ReportList *reports);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-01-05 14:12:07 +00:00
|
|
|
/**
|
2008-12-19 16:36:15 +00:00
|
|
|
* oldmain is old main, from which we will keep libraries, images, ..
|
2006-01-05 14:12:07 +00:00
|
|
|
* file name is current file, only for retrieving library data */
|
|
|
|
|
2014-02-01 00:51:53 +11:00
|
|
|
BlendFileData *BLO_read_from_memfile(
|
|
|
|
struct Main *oldmain, const char *filename, struct MemFile *memfile,
|
|
|
|
struct ReportList *reports);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Free's a BlendFileData structure and _all_ the
|
|
|
|
* data associated with it (the userdef data, and
|
|
|
|
* the main libblock data).
|
2014-02-01 00:51:53 +11:00
|
|
|
*
|
2012-03-02 16:05:54 +00:00
|
|
|
* \param bfd The structure to free.
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
2012-05-12 20:39:39 +00:00
|
|
|
void
|
|
|
|
BLO_blendfiledata_free(BlendFileData *bfd);
|
2014-02-01 00:51:53 +11:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* Open a blendhandle from a file path.
|
2014-02-01 00:51:53 +11:00
|
|
|
*
|
2012-03-02 16:05:54 +00:00
|
|
|
* \param file The file path to open.
|
|
|
|
* \param reports Report errors in opening the file (can be NULL).
|
|
|
|
* \return A handle on success, or NULL on failure.
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
2014-02-01 00:51:53 +11:00
|
|
|
BlendHandle *BLO_blendhandle_from_file(
|
|
|
|
const char *filepath,
|
|
|
|
struct ReportList *reports);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2010-08-28 02:07:55 +00:00
|
|
|
/**
|
|
|
|
* Open a blendhandle from memory.
|
|
|
|
*
|
2012-03-02 16:05:54 +00:00
|
|
|
* \param mem The data to load from.
|
|
|
|
* \param memsize The size of the data.
|
|
|
|
* \return A handle on success, or NULL on failure.
|
2010-08-28 02:07:55 +00:00
|
|
|
*/
|
|
|
|
|
2014-02-01 00:51:53 +11:00
|
|
|
BlendHandle *BLO_blendhandle_from_memory(
|
|
|
|
const void *mem, int memsize);
|
2010-08-28 02:07:55 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* Gets the names of all the datablocks in a file
|
|
|
|
* of a certain type (ie. All the scene names in
|
|
|
|
* a file).
|
2014-02-01 00:51:53 +11:00
|
|
|
*
|
2012-03-02 16:05:54 +00:00
|
|
|
* \param bh The blendhandle to access.
|
|
|
|
* \param ofblocktype The type of names to get.
|
|
|
|
* \param tot_names The length of the returned list.
|
|
|
|
* \return A BLI_linklist of strings. The string links
|
2002-10-12 11:37:38 +00:00
|
|
|
* should be freed with malloc.
|
|
|
|
*/
|
2014-02-01 00:51:53 +11:00
|
|
|
struct LinkNode *BLO_blendhandle_get_datablock_names(
|
|
|
|
BlendHandle *bh,
|
|
|
|
int ofblocktype, int *tot_names);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2007-09-02 17:25:03 +00:00
|
|
|
/**
|
|
|
|
* Gets the previews of all the datablocks in a file
|
|
|
|
* of a certain type (ie. All the scene names in
|
|
|
|
* a file).
|
2014-02-01 00:51:53 +11:00
|
|
|
*
|
2012-03-02 16:05:54 +00:00
|
|
|
* \param bh The blendhandle to access.
|
|
|
|
* \param ofblocktype The type of names to get.
|
|
|
|
* \param tot_prev The length of the returned list.
|
|
|
|
* \return A BLI_linklist of PreviewImage. The PreviewImage links
|
2007-09-02 17:25:03 +00:00
|
|
|
* should be freed with malloc.
|
|
|
|
*/
|
2014-02-01 00:51:53 +11:00
|
|
|
struct LinkNode *BLO_blendhandle_get_previews(
|
|
|
|
BlendHandle *bh,
|
|
|
|
int ofblocktype, int *tot_prev);
|
2007-09-02 17:25:03 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* Gets the names of all the datablock groups in a
|
|
|
|
* file. (ie. file contains Scene, Mesh, and Lamp
|
|
|
|
* datablocks).
|
2014-02-01 00:51:53 +11:00
|
|
|
*
|
2012-03-02 16:05:54 +00:00
|
|
|
* \param bh The blendhandle to access.
|
|
|
|
* \return A BLI_linklist of strings. The string links
|
2002-10-12 11:37:38 +00:00
|
|
|
* should be freed with malloc.
|
|
|
|
*/
|
2014-02-01 00:51:53 +11:00
|
|
|
struct LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Close and free a blendhandle. The handle
|
|
|
|
* becomes invalid after this call.
|
|
|
|
*
|
2012-03-02 16:05:54 +00:00
|
|
|
* \param bh The handle to close.
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
2012-05-12 20:39:39 +00:00
|
|
|
void
|
|
|
|
BLO_blendhandle_close(BlendHandle *bh);
|
2014-02-01 00:51:53 +11:00
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
/***/
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2014-02-01 00:51:53 +11:00
|
|
|
#define BLO_GROUP_MAX 32
|
2009-09-12 19:54:39 +00:00
|
|
|
|
2014-01-31 03:09:01 +11:00
|
|
|
bool BLO_has_bfile_extension(const char *str);
|
2007-12-24 18:53:37 +00:00
|
|
|
|
2014-01-31 03:09:01 +11:00
|
|
|
/**
|
|
|
|
* return ok when a blenderfile, in dir is the filename,
|
2009-09-12 19:54:39 +00:00
|
|
|
* in group the type of libdata
|
|
|
|
*/
|
2014-01-31 03:09:01 +11:00
|
|
|
bool BLO_is_a_library(const char *path, char *dir, char *group);
|
2009-09-12 19:54:39 +00:00
|
|
|
|
2011-08-05 05:26:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the BlendHandle for appending or linking library data.
|
|
|
|
*
|
2012-03-02 16:05:54 +00:00
|
|
|
* \param mainvar The current main database eg G.main or CTX_data_main(C).
|
|
|
|
* \param bh A blender file handle as returned by BLO_blendhandle_from_file or BLO_blendhandle_from_memory.
|
|
|
|
* \param filepath Used for relative linking, copied to the lib->name
|
|
|
|
* \return the library Main, to be passed to BLO_library_append_named_part as mainl.
|
2011-08-05 05:26:19 +00:00
|
|
|
*/
|
2014-02-01 00:51:53 +11:00
|
|
|
struct Main *BLO_library_append_begin(
|
|
|
|
struct Main *mainvar, BlendHandle **bh,
|
|
|
|
const char *filepath);
|
2011-03-13 01:15:14 +00:00
|
|
|
|
2011-05-26 20:45:19 +00:00
|
|
|
|
2011-03-13 01:15:14 +00:00
|
|
|
/**
|
|
|
|
* Link/Append a named datablock from an external blend file.
|
|
|
|
*
|
2012-03-02 16:05:54 +00:00
|
|
|
* \param mainl The main database to link from (not the active one).
|
|
|
|
* \param bh The blender file handle.
|
|
|
|
* \param idname The name of the datablock (without the 2 char ID prefix)
|
|
|
|
* \param idcode The kind of datablock to link.
|
|
|
|
* \return the appended ID when found.
|
2011-05-26 20:45:19 +00:00
|
|
|
*/
|
2014-02-01 00:51:53 +11:00
|
|
|
struct ID *BLO_library_append_named_part(
|
|
|
|
struct Main *mainl, BlendHandle **bh,
|
|
|
|
const char *idname, const int idcode);
|
2011-05-26 20:45:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Link/Append a named datablock from an external blend file.
|
|
|
|
* optionally instance the object in the scene when the flags are set.
|
|
|
|
*
|
2012-03-18 07:38:51 +00:00
|
|
|
* \param C The context, when NULL instancing object in the scene isn't done.
|
2012-03-02 16:05:54 +00:00
|
|
|
* \param mainl The main database to link from (not the active one).
|
|
|
|
* \param bh The blender file handle.
|
|
|
|
* \param idname The name of the datablock (without the 2 char ID prefix)
|
|
|
|
* \param idcode The kind of datablock to link.
|
|
|
|
* \param flag Options for linking, used for instancing.
|
|
|
|
* \return the appended ID when found.
|
2011-03-13 01:15:14 +00:00
|
|
|
*/
|
2014-02-01 00:51:53 +11:00
|
|
|
struct ID *BLO_library_append_named_part_ex(
|
|
|
|
const struct bContext *C, struct Main *mainl, BlendHandle **bh,
|
|
|
|
const char *idname, const int idcode, const short flag);
|
2011-05-26 20:45:19 +00:00
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
void BLO_library_append_end(const struct bContext *C, struct Main *mainl, BlendHandle **bh, int idcode, short flag);
|
2009-09-12 19:54:39 +00:00
|
|
|
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
void BLO_library_append_all(struct Main *mainl, BlendHandle *bh);
|
|
|
|
|
2011-05-18 19:42:30 +00:00
|
|
|
void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname);
|
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
BlendFileData *blo_read_blendafterruntime(int file, const char *name, int actualsize, struct ReportList *reports);
|
2014-02-01 00:51:53 +11:00
|
|
|
|
2012-09-15 01:52:28 +00:00
|
|
|
/* internal function but we need to expose it */
|
|
|
|
void blo_lib_link_screen_restore(struct Main *newmain, struct bScreen *curscreen, struct Scene *curscene);
|
|
|
|
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
/**
|
|
|
|
* BLO_expand_main() loops over all ID data in Main to mark relations.
|
|
|
|
* Set (id->flag & LIB_NEED_EXPAND) to mark expanding. Flags get cleared after expanding.
|
|
|
|
*
|
|
|
|
* \param expand_doit_func() gets called for each ID block it finds
|
|
|
|
*/
|
|
|
|
void BLO_main_expander(void (*expand_doit_func)(void *, struct Main *, void *));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* BLO_expand_main() loops over all ID data in Main to mark relations.
|
|
|
|
* Set (id->flag & LIB_NEED_EXPAND) to mark expanding. Flags get cleared after expanding.
|
|
|
|
*
|
|
|
|
* \param fdhandle usually filedata, or own handle
|
|
|
|
* \param mainvar the Main database to expand
|
|
|
|
*/
|
|
|
|
void BLO_expand_main(void *fdhandle, struct Main *mainvar);
|
2013-09-10 13:25:35 +00:00
|
|
|
|
2014-07-23 20:20:59 +10:00
|
|
|
/* Update defaults in startup.blend & userprefs.blend, without having to save and embed it */
|
|
|
|
void BLO_update_defaults_userpref_blend(void);
|
2013-09-10 13:25:35 +00:00
|
|
|
void BLO_update_defaults_startup_blend(struct Main *mainvar);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-02-01 00:51:53 +11:00
|
|
|
#endif /* __BLO_READFILE_H__ */
|