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