#ifndef _atomFileUtils
#define _atomFileUtils
#include <vector>
#include <set>
#include <string>
#include <map>
#include <maya/MFnAnimCurve.h>
#include <maya/MAngle.h>
#include <maya/MTime.h>
#include <maya/MDistance.h>
#include <maya/MAnimUtil.h>
#include <maya/MFnAttribute.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MVector.h>
#include <maya/MFnUnitAttribute.h>
#include <maya/MPlugArray.h>
#include <maya/MSelectionList.h>
#include <maya/MDGContext.h>
#include <maya/MPlug.h>
#include <maya/MFnAnimCurve.h>
#include "atomNodeNameReplacer.h"
#include <iosfwd>
class atomTemplateReader;
class atomLayerClipboard;
class SelectionGetter
{
public:
static void getSelectedObjects(
bool selectedChildren,
MSelectionList &list, std::vector<unsigned int> &depths);
private:
SelectionGetter(){};
};
class atomCachedPlugs;
class atomBase : public streamIO {
public:
static bool isEquivalent(double, double);
static void getAttrName(
MPlug &plug,
MString &attributeName);
atomBase();
~atomBase() override;
enum AnimBaseType {kAnimBaseUnitless, kAnimBaseTime,
kAnimBaseLinear, kAnimBaseAngular};
AnimBaseType);
AnimBaseType wordAsOutputType(const char *);
AnimBaseType wordAsInputType(const char *);
const char * boolInputTypeAsWord(bool);
MTime getStartTime(){
return mStartTime;}
MTime getEndTime(){
return mEndTime;}
double getStartUnitless(){return mStartUnitless;}
double getEndUnitless(){return mEndUnitless;}
protected:
void resetUnits();
double mStartUnitless;
double mEndUnitless;
};
class atomReader : public atomBase {
public:
atomReader();
~atomReader() override;
MStatus readAtom(std::ifstream &, atomLayerClipboard &atomClipboard,
MSelectionList &mList,atomNodeNameReplacer & replacer,
MString& exportEditsFile,
bool &removeExportEditsFile, atomTemplateReader &reader,
bool replaceLayers);
void setImportFrameRange( double pImportStartFrame, double pImportEndFrame )
{
mImportStartFrame = pImportStartFrame;
mImportEndFrame = pImportEndFrame;
mImportCustomFrameRange = true;
}
void clearImportFrameRange()
{
mImportCustomFrameRange = false;
}
protected:
char * readStaticValue(
MString &nodeName,
char *dataType,
unsigned int depth, unsigned int childCount,std::ifstream &readAnim,
atomLayerClipboard &cb, atomTemplateReader &reader);
char * readHeader(std::ifstream &readAnim, bool &hasVersionString,double &startTime, double &endTime, double &startUnitless, double &endUnitless);
char * readExportEditsFile(
char*, std::ifstream&,
MString& filename,
bool &removeExportEditsFile);
char * readExportEditsFilePresent(
char*, std::ifstream&,
bool &present,
MString &filename);
MStatus readNodes(
char *dataType,std::ifstream &readAnim, atomLayerClipboard &cb,
MSelectionList &mList, atomNodeNameReplacer & replacer,atomTemplateReader &reader,
bool replaceLayers,
MString& exportEditsFile,
bool &removeExportEditsFile);
char *skipToNextParenth(char *dataType, std::ifstream &readAnim,int parenthCount = 1);
char * readCachedValues(
MString &nodeName,
char *dataType,
unsigned int depth, unsigned int childCount,std::ifstream &readAnim,
atomLayerClipboard &cb,atomTemplateReader &reader);
char * putCachedOnAnimCurve(
MString &nodeName,
MString &attributeName,
char *dataType, std::ifstream &readAnim,
void addDynamicAttributeIfNeeded(
MString& nodeName,
bool convertAnglesFromV2To3;
bool convertAnglesFromV3To2;
double mImportStartFrame;
double mImportEndFrame;
bool mImportCustomFrameRange;
double animVersion;
};
class atomWriter : public atomBase {
public:
atomWriter();
~atomWriter() override;
bool writeHeader(std::ofstream&,
bool useSpedifiedTimes,
MTime &startTime,
MTime &endTime);
bool writeExportEditsFile(std::ofstream&,
const MString& filename);
bool writeExportEditsFilePresent(std::ofstream&);
void writeStaticValues (
std::ofstream &animFile,
std::set<std::string> &attrStrings,
unsigned int depth,
unsigned int childCount,
atomTemplateReader &templateReader
);
void writeCachedValues (
std::ofstream &animFile,
atomCachedPlugs *cachedPlugs,
std::set<std::string> &attrStrings,
unsigned int depth,
unsigned int childCount,
atomTemplateReader &templateReader
);
void writeNodeStart(std::ofstream&,atomNodeNameReplacer::NodeType nodeType,
MString &name,
unsigned int depth =0,
unsigned int childCount =0);
void writeNodeEnd(std::ofstream&);
protected:
bool writeAnimCurve( std::ofstream&,
const MObject *,
bool = false);
void writeValue(std::ofstream & clip,
MPlug &plug);
};
class atomUnitNames {
public:
atomUnitNames();
virtual ~atomUnitNames();
};
class atomTemplateReader
{
public:
atomTemplateReader():fTemplateSet(false){}
~atomTemplateReader();
bool findNode(
const MString &name);
void selectNodes();
bool isTemplateSet(){return fTemplateSet;}
protected:
bool fTemplateSet;
struct Attrs
{
~Attrs() {fAttrStrings.clear();}
std::set<std::string> fAttrStrings;
};
typedef std::map< std::string, Attrs > AttrMap;
AttrMap fNodeAttrs;
};
#endif