|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TLEVEL_IO_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define TLEVEL_IO_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tlevel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "timage_io.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tproperty.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
9f5a1b |
#ifdef _WIN32
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#pragma warning(disable : 4290)
|
|
Toshihiro Shimizu |
890ddd |
#pragma warning(disable : 4251)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <typeinfo></typeinfo>
|
|
Toshihiro Shimizu |
890ddd |
namespace std
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
using ::type_info;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TIMAGE_IO_EXPORTS
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_EXPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_EXPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_IMPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_IMPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================
|
|
Toshihiro Shimizu |
890ddd |
// forward declaration
|
|
Toshihiro Shimizu |
890ddd |
class TSoundTrack;
|
|
Toshihiro Shimizu |
890ddd |
class TImageInfo;
|
|
Toshihiro Shimizu |
890ddd |
class TContentHistory;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TLevelReader;
|
|
Toshihiro Shimizu |
890ddd |
typedef TLevelReader *TLevelReaderCreateProc(const TFilePath &path);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TLevelReader : public TSmartObject
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
DECLARE_CLASS_CODE
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
TImageInfo *m_info;
|
|
Toshihiro Shimizu |
890ddd |
TFilePath m_path;
|
|
Toshihiro Shimizu |
890ddd |
TContentHistory *m_contentHistory;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TLevelReader(const TFilePath &path);
|
|
Toshihiro Shimizu |
890ddd |
virtual ~TLevelReader();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
// not implemented
|
|
Toshihiro Shimizu |
890ddd |
TLevelReader(const TLevelReader &);
|
|
Toshihiro Shimizu |
890ddd |
TLevelReader &operator=(const TLevelReader &src);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
virtual TLevelP loadInfo();
|
|
Toshihiro Shimizu |
890ddd |
virtual QString getCreator() { return ""; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
virtual void doReadPalette(bool) {}
|
|
Toshihiro Shimizu |
890ddd |
virtual void enableRandomAccessRead(bool) {}
|
|
Toshihiro Shimizu |
890ddd |
virtual TImageReaderP getFrameReader(TFrameId);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TLevelReader keeps ownership: DO NOT DELETE
|
|
Toshihiro Shimizu |
890ddd |
virtual const TImageInfo *getImageInfo(TFrameId);
|
|
Toshihiro Shimizu |
890ddd |
virtual const TImageInfo *getImageInfo();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TImageReaderP getFrameReader(int f)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return getFrameReader(TFrameId(f));
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
virtual TSoundTrack *loadSoundTrack();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFilePath getFilePath() const { return m_path; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static void getSupportedFormats(QStringList &names);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
enum FormatType {
|
|
Toshihiro Shimizu |
890ddd |
UnsupportedFormat,
|
|
Toshihiro Shimizu |
890ddd |
RasterLevel,
|
|
Toshihiro Shimizu |
890ddd |
VectorLevel
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
static FormatType getFormatType(std::string extension);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static void define(
|
|
Toshihiro Shimizu |
890ddd |
QString extension,
|
|
Toshihiro Shimizu |
890ddd |
int reader,
|
|
Toshihiro Shimizu |
890ddd |
// nel caso in cui ci siano piu' lettori per lo stesso formato
|
|
Toshihiro Shimizu |
890ddd |
// (es. flash)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TLevelReaderCreateProc *proc);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static inline void define(
|
|
Toshihiro Shimizu |
890ddd |
QString extension,
|
|
Toshihiro Shimizu |
890ddd |
TLevelReaderCreateProc *proc) { define(extension, 0, proc); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! TLevelReader keeps the ownership of TContentHistory. Don't delete it
|
|
Toshihiro Shimizu |
890ddd |
const TContentHistory *getContentHistory() const { return m_contentHistory; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
TFrameId::FrameFormat m_frameFormat;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
9f5a1b |
#ifdef _WIN32
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TSmartPointerT<tlevelreader>;</tlevelreader>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TLevelReaderP : public TSmartPointerT<tlevelreader></tlevelreader>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
// il costruttore "non banale"
|
|
Toshihiro Shimizu |
890ddd |
TLevelReaderP(const TFilePath &filepath, int reader = 0);
|
|
Toshihiro Shimizu |
890ddd |
// il costruttore di default
|
|
Toshihiro Shimizu |
890ddd |
TLevelReaderP() {}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TLevelWriter;
|
|
Toshihiro Shimizu |
890ddd |
class TPropertyGroup;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
typedef TLevelWriter *TLevelWriterCreateProc(const TFilePath &path, TPropertyGroup *);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
typedef TPropertyGroup *TWriterInfoCreateProc(const std::string &ext);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TLevelWriter : public TSmartObject
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
DECLARE_CLASS_CODE
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
TFilePath m_path;
|
|
Toshihiro Shimizu |
890ddd |
double m_frameRate;
|
|
Toshihiro Shimizu |
890ddd |
TPropertyGroup *m_properties;
|
|
Toshihiro Shimizu |
890ddd |
TContentHistory *m_contentHistory;
|
|
Toshihiro Shimizu |
890ddd |
QString m_creator;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TLevelWriter(const TFilePath &path, TPropertyGroup *winfo = 0); //ottiene l'ownership
|
|
Toshihiro Shimizu |
890ddd |
virtual ~TLevelWriter();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void setCreator(const QString &creator) { m_creator = creator; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
virtual void setPalette(TPalette *){};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
virtual void setOverwritePaletteFlag(bool overwrite){};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Maps a list of existing level frames to a new list of frames.
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Toshihiro Shimizu |
890ddd |
This function allows an existing level to reorganize (or discard)
|
|
Toshihiro Shimizu |
890ddd |
its \a disk content. It is typically implemented by TLevelWriters
|
|
Toshihiro Shimizu |
890ddd |
that support random access writing <\I>, which can therefore
|
|
Toshihiro Shimizu |
890ddd |
write new frames on top of an existing level.
|
|
Toshihiro Shimizu |
890ddd |
\n\n
|
|
Toshihiro Shimizu |
890ddd |
This function requires that frames present on disk \a and in the
|
|
Toshihiro Shimizu |
890ddd |
table be remapped, while frames on disk \a not in the table be
|
|
Toshihiro Shimizu |
890ddd |
\b deleted. Eventual frames present in the table but not on disk
|
|
Toshihiro Shimizu |
890ddd |
are ignored.
|
|
Toshihiro Shimizu |
890ddd |
\n\n
|
|
Toshihiro Shimizu |
890ddd |
The default implementation provides renumbering for standard
|
|
Toshihiro Shimizu |
890ddd |
Toonz multi-file level types (levelName.####c.ext), and does nothing
|
|
Toshihiro Shimizu |
890ddd |
if the specified path is not compatible with the multi-file format.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
virtual void renumberFids(const std::map<tframeid, tframeid=""> &table);</tframeid,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Usate per le TLV
|
|
Toshihiro Shimizu |
890ddd |
// Introdotte per le TLV (versione 13) che salvano l'iconcina
|
|
Toshihiro Shimizu |
890ddd |
// nel file stesso.
|
|
Toshihiro Shimizu |
890ddd |
virtual void setIconSize(TDimension){};
|
|
Toshihiro Shimizu |
890ddd |
virtual TDimension getIconSize() const { return TDimension(); };
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
// not implemented
|
|
Toshihiro Shimizu |
890ddd |
TLevelWriter(const TLevelWriter &);
|
|
Toshihiro Shimizu |
890ddd |
TLevelWriter &operator=(const TLevelWriter &src);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
virtual TImageWriterP getFrameWriter(TFrameId);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TImageWriterP getFrameWriter(int f)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return getFrameWriter(TFrameId(f));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPropertyGroup *getProperties() { return m_properties; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void save(const TLevelP &level);
|
|
Toshihiro Shimizu |
890ddd |
virtual void saveSoundTrack(TSoundTrack *st);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
virtual void setFrameRate(double fps);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFilePath getFilePath() const { return m_path; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static void getSupportedFormats(QStringList &names, bool onlyRenderFormats);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// note gets the contentHistory. can be 0
|
|
Toshihiro Shimizu |
890ddd |
const TContentHistory *getContentHistory() const { return m_contentHistory; }
|
|
Toshihiro Shimizu |
890ddd |
TContentHistory *getContentHistory() { return m_contentHistory; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// destroys the old contentHistory and replaces it with the new one. Gets ownership
|
|
Toshihiro Shimizu |
890ddd |
// note. set the content history first
|
|
Toshihiro Shimizu |
890ddd |
void setContentHistory(TContentHistory *contentHistory);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static void define(
|
|
Toshihiro Shimizu |
890ddd |
QString extension,
|
|
Toshihiro Shimizu |
890ddd |
TLevelWriterCreateProc *proc, bool isRenderFormat);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
9f5a1b |
#ifdef _WIN32
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TSmartPointerT<tlevelwriter>;</tlevelwriter>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TLevelWriterP : public TSmartPointerT<tlevelwriter></tlevelwriter>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
// il costruttore "non banale"
|
|
Toshihiro Shimizu |
890ddd |
TLevelWriterP(const TFilePath &filepath, TPropertyGroup *winfo = 0); //non si prende l'ownership del TPropertyGroup
|
|
Toshihiro Shimizu |
890ddd |
// il costruttore di default
|
|
Toshihiro Shimizu |
890ddd |
TLevelWriterP() {}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Some useful utility inlines
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
inline bool isMovieType(std::string type)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return (type == "mov" || type == "avi" || type == "3gp");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline bool isMovieType(const TFilePath &fp)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
3bfa54 |
std::string type(fp.getType());
|
|
Toshihiro Shimizu |
890ddd |
return isMovieType(type);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline bool doesSupportRandomAccess(const TFilePath &fp, bool isToonzOutput = false)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return (fp.getDots() == "..") || (isToonzOutput && fp.getType() == "mov");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|