|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/cleanupparameters.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstream.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "texception.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzscene.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/sceneproperties.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshleveltypes.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tsystem.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tenv.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tconvert.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "cleanuppalette.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpalette.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef WIN32
|
|
Toshihiro Shimizu |
890ddd |
#pragma warning(disable : 4996)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using namespace CleanupTypes;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#define FDG_VERSION_FILE "VERSION_1.0"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
CleanupParameters CleanupParameters::GlobalParameters;
|
|
Toshihiro Shimizu |
890ddd |
CleanupParameters CleanupParameters::LastSavedParameters;
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class FdgManager
|
|
Toshihiro Shimizu |
890ddd |
{ // singleton
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::map<string, fdg_info=""> m_infos;</string,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void loadFieldGuideInfo();
|
|
Toshihiro Shimizu |
890ddd |
FdgManager() { loadFieldGuideInfo(); }
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
static FdgManager *instance()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
static FdgManager _instance;
|
|
Toshihiro Shimizu |
890ddd |
return &_instance;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const FDG_INFO *getFdg(string name) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::map<string, fdg_info="">::const_iterator it;</string,>
|
|
Toshihiro Shimizu |
890ddd |
it = m_infos.find(name);
|
|
Toshihiro Shimizu |
890ddd |
if (it == m_infos.end())
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
return &it->second;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void getFdgNames(vector<string> &names) const</string>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::map<string, fdg_info="">::const_iterator it;</string,>
|
|
Toshihiro Shimizu |
890ddd |
for (it = m_infos.begin(); it != m_infos.end(); ++it)
|
|
Toshihiro Shimizu |
890ddd |
names.push_back(it->first);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#define REMOVE_CR(s) \
|
|
Toshihiro Shimizu |
890ddd |
{ \
|
|
Toshihiro Shimizu |
890ddd |
while (*(s) && *(s) != '\n' && *(s) != '\r') \
|
|
Toshihiro Shimizu |
890ddd |
(s)++; \
|
|
Toshihiro Shimizu |
890ddd |
*(s) = '\0'; \
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#define SKIP_BLANKS(s) \
|
|
Toshihiro Shimizu |
890ddd |
{ \
|
|
Toshihiro Shimizu |
890ddd |
while (*(s) && (*(s) == ' ' || *(s) == '\t')) \
|
|
Toshihiro Shimizu |
890ddd |
(s)++; \
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#define STR_EQ(s1, s2) (!strcmp((s1), (s2)))
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FdgManager::loadFieldGuideInfo()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
FILE *fp;
|
|
Toshihiro Shimizu |
890ddd |
char *s, buffer[256], label[100], arg[100];
|
|
Toshihiro Shimizu |
890ddd |
int i, version = 0, cnt;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
try {
|
|
Toshihiro Shimizu |
890ddd |
TFilePathSet fps = TSystem::readDirectory(TEnv::getConfigDir() + "fdg", false);
|
|
Toshihiro Shimizu |
890ddd |
for (TFilePathSet::iterator it = fps.begin(); it != fps.end(); ++it) {
|
|
Toshihiro Shimizu |
890ddd |
TFilePath fname = *it;
|
|
Toshihiro Shimizu |
890ddd |
if (fname.getType() != "fdg")
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
fp = fopen(toString(fname.getWideString()).c_str(), "r");
|
|
Toshihiro Shimizu |
890ddd |
if (!fp)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
FDG_INFO fdg_info;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//memset(&fdg_info,0, sizeof(FDG_INFO));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
fdg_info.dots.resize(3);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
cnt = 0;
|
|
Toshihiro Shimizu |
890ddd |
while (fgets(buffer, 256, fp)) {
|
|
Toshihiro Shimizu |
890ddd |
s = buffer;
|
|
Toshihiro Shimizu |
890ddd |
if (*s == '#' || *s == '*')
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
REMOVE_CR(s)
|
|
Toshihiro Shimizu |
890ddd |
s = buffer;
|
|
Toshihiro Shimizu |
890ddd |
SKIP_BLANKS(s)
|
|
Toshihiro Shimizu |
890ddd |
if (!*s)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; *s && *s != ' ' && *s != '\t'; i++, s++)
|
|
Toshihiro Shimizu |
890ddd |
label[i] = *s;
|
|
Toshihiro Shimizu |
890ddd |
label[i] = '\0';
|
|
Toshihiro Shimizu |
890ddd |
SKIP_BLANKS(s)
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; *s && *s != ' ' && *s != '\t'; i++, s++)
|
|
Toshihiro Shimizu |
890ddd |
arg[i] = *s;
|
|
Toshihiro Shimizu |
890ddd |
arg[i] = '\0';
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* suppongo ci siano sempre 3 dots */
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (STR_EQ(label, FDG_VERSION_FILE))
|
|
Toshihiro Shimizu |
890ddd |
version = 1;
|
|
Toshihiro Shimizu |
890ddd |
else if (STR_EQ(label, "CTRX"))
|
|
Toshihiro Shimizu |
890ddd |
sscanf(arg, "%lf", &fdg_info.ctr_x), fdg_info.ctr_type = 1;
|
|
Toshihiro Shimizu |
890ddd |
else if (STR_EQ(label, "CTRY"))
|
|
Toshihiro Shimizu |
890ddd |
sscanf(arg, "%lf", &fdg_info.ctr_y), fdg_info.ctr_type = 1;
|
|
Toshihiro Shimizu |
890ddd |
else if (STR_EQ(label, "ANGLE"))
|
|
Toshihiro Shimizu |
890ddd |
sscanf(arg, "%lf", &fdg_info.ctr_angle), fdg_info.ctr_type = 1;
|
|
Toshihiro Shimizu |
890ddd |
else if (STR_EQ(label, "SKEW"))
|
|
Toshihiro Shimizu |
890ddd |
sscanf(arg, "%lf", &fdg_info.ctr_skew), fdg_info.ctr_type = 1;
|
|
Toshihiro Shimizu |
890ddd |
else if (STR_EQ(label, "HOLE")) {
|
|
Toshihiro Shimizu |
890ddd |
sscanf(arg, "%d", &cnt);
|
|
Toshihiro Shimizu |
890ddd |
if (cnt >= (int)fdg_info.dots.size()) {
|
|
Toshihiro Shimizu |
890ddd |
// tmsg_error("load field guide info error: bad hole number");
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
// return FALSE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else if (STR_EQ(label, "X0"))
|
|
Toshihiro Shimizu |
890ddd |
sscanf(arg, "%d", &fdg_info.dots[cnt].x1);
|
|
Toshihiro Shimizu |
890ddd |
else if (STR_EQ(label, "Y0"))
|
|
Toshihiro Shimizu |
890ddd |
sscanf(arg, "%d", &fdg_info.dots[cnt].y1);
|
|
Toshihiro Shimizu |
890ddd |
else if (STR_EQ(label, "X1"))
|
|
Toshihiro Shimizu |
890ddd |
sscanf(arg, "%d", &fdg_info.dots[cnt].x2);
|
|
Toshihiro Shimizu |
890ddd |
else if (STR_EQ(label, "Y1"))
|
|
Toshihiro Shimizu |
890ddd |
sscanf(arg, "%d", &fdg_info.dots[cnt].y2);
|
|
Toshihiro Shimizu |
890ddd |
else if (STR_EQ(label, "X"))
|
|
Toshihiro Shimizu |
890ddd |
sscanf(arg, "%f", &fdg_info.dots[cnt].x);
|
|
Toshihiro Shimizu |
890ddd |
else if (STR_EQ(label, "Y"))
|
|
Toshihiro Shimizu |
890ddd |
sscanf(arg, "%f", &fdg_info.dots[cnt].y);
|
|
Toshihiro Shimizu |
890ddd |
else if (STR_EQ(label, "XSIZE"))
|
|
Toshihiro Shimizu |
890ddd |
sscanf(arg, "%d", &fdg_info.dots[cnt].lx);
|
|
Toshihiro Shimizu |
890ddd |
else if (STR_EQ(label, "YSIZE"))
|
|
Toshihiro Shimizu |
890ddd |
sscanf(arg, "%d", &fdg_info.dots[cnt].ly);
|
|
Toshihiro Shimizu |
890ddd |
else if (STR_EQ(label, "AREA"))
|
|
Toshihiro Shimizu |
890ddd |
sscanf(arg, "%d", &fdg_info.dots[cnt].area);
|
|
Toshihiro Shimizu |
890ddd |
else if (STR_EQ(label, "END")) {
|
|
Toshihiro Shimizu |
890ddd |
} else if (STR_EQ(label, "DIST_CTR_TO_CTR_HOLE"))
|
|
Toshihiro Shimizu |
890ddd |
sscanf(arg, "%lf", &fdg_info.dist_ctr_to_ctr_hole);
|
|
Toshihiro Shimizu |
890ddd |
else if (STR_EQ(label, "DIST_CTR_HOLE_TO_EDGE"))
|
|
Toshihiro Shimizu |
890ddd |
sscanf(arg, "%lf", &fdg_info.dist_ctr_hole_to_edge);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
fclose(fp);
|
|
Toshihiro Shimizu |
890ddd |
if (!fdg_info.ctr_type && version != 1) {
|
|
Toshihiro Shimizu |
890ddd |
// tmsg_error("load field guide info: bad file or old version");
|
|
Toshihiro Shimizu |
890ddd |
// return FALSE;
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
fdg_info.m_name = fname.getName();
|
|
Toshihiro Shimizu |
890ddd |
m_infos[fdg_info.m_name] = fdg_info;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} catch (...) {
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//return TRUE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
CleanupParameters::CleanupParameters()
|
|
Toshihiro Shimizu |
890ddd |
: m_autocenterType(AUTOCENTER_NONE), m_pegSide(PEGS_BOTTOM), m_fdgInfo(), m_rotate(0), m_flipx(false), m_flipy(false), m_offx(0), m_offy(0)
|
|
Toshihiro Shimizu |
890ddd |
//, m_scale(1)
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_lineProcessingMode(lpGrey), m_noAntialias(false), m_postAntialias(false), m_despeckling(2), m_aaValue(70), m_closestField(10.), m_sharpness(90.), m_autoAdjustMode(AUTO_ADJ_NONE), m_transparencyCheckEnabled(false), m_colors(), m_path(), m_cleanupPalette(createStandardCleanupPalette()), m_camera(), m_dirtyFlag(false)
|
|
Toshihiro Shimizu |
890ddd |
//, m_resName("")
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_offx_lock(false), m_offy_lock(false)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool CleanupParameters::setFdgByName(string name)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
const FDG_INFO *info = FdgManager::instance()->getFdg(name);
|
|
Toshihiro Shimizu |
890ddd |
if (info) {
|
|
Toshihiro Shimizu |
890ddd |
m_fdgInfo = *info;
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
m_fdgInfo = FDG_INFO();
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void CleanupParameters::getFdgNames(vector<string> &names)</string>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
FdgManager::instance()->getFdgNames(names);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFilePath CleanupParameters::getPath(ToonzScene *scene) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_path == TFilePath()) {
|
|
Toshihiro Shimizu |
890ddd |
int levelType = (m_lineProcessingMode != lpNone) ? TZP_XSHLEVEL : OVL_XSHLEVEL;
|
|
Toshihiro Shimizu |
890ddd |
TFilePath fp = scene->getDefaultLevelPath(levelType);
|
|
Toshihiro Shimizu |
890ddd |
return fp.getParentDir();
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
return scene->decodeSavePath(m_path);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void CleanupParameters::setPath(ToonzScene *scene, TFilePath fp)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (fp == scene->getDefaultLevelPath(TZP_XSHLEVEL).getParentDir())
|
|
Toshihiro Shimizu |
890ddd |
m_path = TFilePath();
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
m_path = scene->codeSavePath(fp);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void CleanupParameters::getOutputImageInfo(
|
|
Toshihiro Shimizu |
890ddd |
TDimension &outDim, double &outDpiX, double &outDpiY) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
double lq_nozoom, lp_nozoom;
|
|
Toshihiro Shimizu |
890ddd |
double zoom_factor;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Retrieve camera infos
|
|
Toshihiro Shimizu |
890ddd |
const TDimensionD &cameraSize = m_camera.getSize();
|
|
Toshihiro Shimizu |
890ddd |
const TDimension &cameraRes = m_camera.getRes();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Camera resolution
|
|
Toshihiro Shimizu |
890ddd |
lp_nozoom = cameraRes.lx;
|
|
Toshihiro Shimizu |
890ddd |
lq_nozoom = cameraRes.ly;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Zoom factor due to the 'closest field' parameter
|
|
Toshihiro Shimizu |
890ddd |
if (m_closestField < cameraSize.lx)
|
|
Toshihiro Shimizu |
890ddd |
zoom_factor = cameraSize.lx / m_closestField;
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
zoom_factor = 1.0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Output image resolution (considering the closest field)
|
|
Toshihiro Shimizu |
890ddd |
// apart from any rotation (eg m_parameters.m_rotate == 90 or 270)
|
|
Toshihiro Shimizu |
890ddd |
outDim.lx = troundp(zoom_factor * lp_nozoom);
|
|
Toshihiro Shimizu |
890ddd |
outDim.ly = troundp(zoom_factor * lq_nozoom);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// output image dpi
|
|
Toshihiro Shimizu |
890ddd |
outDpiX = zoom_factor * cameraRes.lx / cameraSize.lx;
|
|
Toshihiro Shimizu |
890ddd |
outDpiY = zoom_factor * cameraRes.ly / cameraSize.ly;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void CleanupParameters::assign(const CleanupParameters *param, bool clonePalette)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
//m_resName = param->m_resName;
|
|
Toshihiro Shimizu |
890ddd |
m_camera = param->m_camera;
|
|
Toshihiro Shimizu |
890ddd |
m_autocenterType = param->m_autocenterType;
|
|
Toshihiro Shimizu |
890ddd |
m_pegSide = param->m_pegSide;
|
|
Toshihiro Shimizu |
890ddd |
m_fdgInfo = param->m_fdgInfo;
|
|
Toshihiro Shimizu |
890ddd |
m_rotate = param->m_rotate;
|
|
Toshihiro Shimizu |
890ddd |
m_flipx = param->m_flipx;
|
|
Toshihiro Shimizu |
890ddd |
m_flipy = param->m_flipy;
|
|
Toshihiro Shimizu |
890ddd |
//m_scale = param->m_scale;
|
|
Toshihiro Shimizu |
890ddd |
m_offx = param->m_offx;
|
|
Toshihiro Shimizu |
890ddd |
m_offy = param->m_offy;
|
|
Toshihiro Shimizu |
890ddd |
m_closestField = param->m_closestField;
|
|
Toshihiro Shimizu |
890ddd |
m_autoAdjustMode = param->m_autoAdjustMode;
|
|
Toshihiro Shimizu |
890ddd |
m_sharpness = param->m_sharpness;
|
|
Toshihiro Shimizu |
890ddd |
m_path = param->m_path;
|
|
Toshihiro Shimizu |
890ddd |
m_colors = param->m_colors;
|
|
Toshihiro Shimizu |
890ddd |
m_dirtyFlag = param->m_dirtyFlag;
|
|
Toshihiro Shimizu |
890ddd |
m_transparencyCheckEnabled = param->m_transparencyCheckEnabled;
|
|
Toshihiro Shimizu |
890ddd |
m_lineProcessingMode = param->m_lineProcessingMode;
|
|
Toshihiro Shimizu |
890ddd |
m_noAntialias = param->m_noAntialias;
|
|
Toshihiro Shimizu |
890ddd |
m_postAntialias = param->m_postAntialias;
|
|
Toshihiro Shimizu |
890ddd |
m_despeckling = param->m_despeckling;
|
|
Toshihiro Shimizu |
890ddd |
m_aaValue = param->m_aaValue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//In modern Toonz scenes, there always is a cleanup palette.
|
|
Toshihiro Shimizu |
890ddd |
//In older Toonz scenes, it may be missing. In this case, leave the current one.
|
|
Toshihiro Shimizu |
890ddd |
if (clonePalette && param->m_cleanupPalette)
|
|
Toshihiro Shimizu |
890ddd |
m_cleanupPalette = param->m_cleanupPalette->clone();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_offx_lock = param->m_offx_lock;
|
|
Toshihiro Shimizu |
890ddd |
m_offy_lock = param->m_offy_lock;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void CleanupParameters::saveData(TOStream &os) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
CleanupParameters::LastSavedParameters.assign(this);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
os.openChild("cleanupCamera");
|
|
Toshihiro Shimizu |
890ddd |
m_camera.saveData(os);
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
os.openChild("cleanupPalette");
|
|
Toshihiro Shimizu |
890ddd |
m_cleanupPalette->saveData(os);
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::map<string, string=""> attr;</string,>
|
|
Toshihiro Shimizu |
890ddd |
if (m_autocenterType != AUTOCENTER_NONE) {
|
|
Toshihiro Shimizu |
890ddd |
attr.clear();
|
|
Toshihiro Shimizu |
890ddd |
attr["type"] = toString((int)m_autocenterType);
|
|
Toshihiro Shimizu |
890ddd |
attr["pegHoles"] = toString((int)m_pegSide);
|
|
Toshihiro Shimizu |
890ddd |
//attr["fieldGuide"] = toString((int)m_pegSide);
|
|
Toshihiro Shimizu |
890ddd |
os.openCloseChild("autoCenter", attr);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_flipx || m_flipy || m_rotate != 0 //|| m_scale!=1
|
|
Toshihiro Shimizu |
890ddd |
|| m_offx != 0 || m_offy != 0) {
|
|
Toshihiro Shimizu |
890ddd |
attr.clear();
|
|
Toshihiro Shimizu |
890ddd |
string flip = string(m_flipx ? "x" : "") + string(m_flipy ? "y" : "");
|
|
Toshihiro Shimizu |
890ddd |
if (flip != "")
|
|
Toshihiro Shimizu |
890ddd |
attr["flip"] = flip;
|
|
Toshihiro Shimizu |
890ddd |
if (m_rotate != 0)
|
|
Toshihiro Shimizu |
890ddd |
attr["rotate"] = toString(m_rotate);
|
|
Toshihiro Shimizu |
890ddd |
//if(m_scale!=1) attr["scale"] = toString(m_scale);
|
|
Toshihiro Shimizu |
890ddd |
if (m_offx != 0.0)
|
|
Toshihiro Shimizu |
890ddd |
attr["xoff"] = toString(m_offx);
|
|
Toshihiro Shimizu |
890ddd |
if (m_offy != 0.0)
|
|
Toshihiro Shimizu |
890ddd |
attr["yoff"] = toString(m_offy);
|
|
Toshihiro Shimizu |
890ddd |
os.openCloseChild("transform", attr);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_lineProcessingMode != lpNone) {
|
|
Toshihiro Shimizu |
890ddd |
attr.clear();
|
|
Toshihiro Shimizu |
890ddd |
attr["sharpness"] = toString(m_sharpness);
|
|
Toshihiro Shimizu |
890ddd |
attr["autoAdjust"] = toString((int)m_autoAdjustMode);
|
|
Toshihiro Shimizu |
890ddd |
attr["mode"] = (m_lineProcessingMode == lpGrey ? "grey" : "color");
|
|
Toshihiro Shimizu |
890ddd |
os.openCloseChild("lineProcessing", attr);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_noAntialias) {
|
|
Toshihiro Shimizu |
890ddd |
attr.clear();
|
|
Toshihiro Shimizu |
890ddd |
os.openCloseChild("noAntialias", attr);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_postAntialias) {
|
|
Toshihiro Shimizu |
890ddd |
attr.clear();
|
|
Toshihiro Shimizu |
890ddd |
os.openCloseChild("MLAA", attr);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
attr.clear();
|
|
Toshihiro Shimizu |
890ddd |
attr["value"] = toString(m_despeckling);
|
|
Toshihiro Shimizu |
890ddd |
os.openCloseChild("despeckling", attr);
|
|
Toshihiro Shimizu |
890ddd |
attr.clear();
|
|
Toshihiro Shimizu |
890ddd |
attr["value"] = toString(m_aaValue);
|
|
Toshihiro Shimizu |
890ddd |
os.openCloseChild("aaValue", attr);
|
|
Toshihiro Shimizu |
890ddd |
attr.clear();
|
|
Toshihiro Shimizu |
890ddd |
attr["value"] = toString(m_closestField);
|
|
Toshihiro Shimizu |
890ddd |
os.openCloseChild("closestField", attr);
|
|
Toshihiro Shimizu |
890ddd |
attr.clear();
|
|
Toshihiro Shimizu |
890ddd |
attr["name"] = m_fdgInfo.m_name;
|
|
Toshihiro Shimizu |
890ddd |
os.openCloseChild("fdg", attr);
|
|
Toshihiro Shimizu |
890ddd |
attr.clear();
|
|
Toshihiro Shimizu |
890ddd |
if (m_path != TFilePath())
|
|
Toshihiro Shimizu |
890ddd |
os.child("path") << m_path;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// attr["path"] = toString(m_path.getWideString());
|
|
Toshihiro Shimizu |
890ddd |
// os.openCloseChild("path", attr);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//m_closestField = param->m_closestField;
|
|
Toshihiro Shimizu |
890ddd |
//m_autoAdjustMode = param->m_autoAdjustMode;
|
|
Toshihiro Shimizu |
890ddd |
//m_sharpness = param->m_sharpness;
|
|
Toshihiro Shimizu |
890ddd |
//m_transparencyCheckEnabled = param->m_transparencyCheckEnabled;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void CleanupParameters::loadData(TIStream &is, bool globalParams)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (globalParams) {
|
|
Toshihiro Shimizu |
890ddd |
CleanupParameters cp;
|
|
Toshihiro Shimizu |
890ddd |
assign(&cp);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
string tagName;
|
|
Toshihiro Shimizu |
890ddd |
m_lineProcessingMode = lpNone;
|
|
Toshihiro Shimizu |
890ddd |
m_noAntialias = false;
|
|
Toshihiro Shimizu |
890ddd |
m_postAntialias = false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
while (is.matchTag(tagName)) {
|
|
Toshihiro Shimizu |
890ddd |
if (tagName == "cleanupPalette") {
|
|
Toshihiro Shimizu |
890ddd |
m_cleanupPalette->loadData(is);
|
|
Toshihiro Shimizu |
890ddd |
m_cleanupPalette->setIsCleanupPalette(true);
|
|
Toshihiro Shimizu |
890ddd |
is.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "cleanupCamera") {
|
|
Toshihiro Shimizu |
890ddd |
m_camera.loadData(is);
|
|
Toshihiro Shimizu |
890ddd |
is.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "autoCenter") {
|
|
Toshihiro Shimizu |
890ddd |
m_autocenterType = AUTOCENTER_FDG;
|
|
Toshihiro Shimizu |
890ddd |
string s = is.getTagAttribute("type");
|
|
Toshihiro Shimizu |
890ddd |
if (s != "" && isInt(s))
|
|
Toshihiro Shimizu |
890ddd |
m_autocenterType = (AUTOCENTER_TYPE)toInt(s);
|
|
Toshihiro Shimizu |
890ddd |
s = is.getTagAttribute("pegHoles");
|
|
Toshihiro Shimizu |
890ddd |
if (s != "" && isInt(s))
|
|
Toshihiro Shimizu |
890ddd |
m_pegSide = (PEGS_SIDE)toInt(s);
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "transform") {
|
|
Toshihiro Shimizu |
890ddd |
string s = is.getTagAttribute("flip");
|
|
Toshihiro Shimizu |
890ddd |
m_flipx = (s.find("x") != string::npos);
|
|
Toshihiro Shimizu |
890ddd |
m_flipy = (s.find("y") != string::npos);
|
|
Toshihiro Shimizu |
890ddd |
s = is.getTagAttribute("rotate");
|
|
Toshihiro Shimizu |
890ddd |
if (s != "" && isInt(s))
|
|
Toshihiro Shimizu |
890ddd |
m_rotate = toInt(s);
|
|
Toshihiro Shimizu |
890ddd |
s = is.getTagAttribute("xoff");
|
|
Toshihiro Shimizu |
890ddd |
if (s != "" && isDouble(s))
|
|
Toshihiro Shimizu |
890ddd |
m_offx = toDouble(s);
|
|
Toshihiro Shimizu |
890ddd |
s = is.getTagAttribute("yoff");
|
|
Toshihiro Shimizu |
890ddd |
if (s != "" && isDouble(s))
|
|
Toshihiro Shimizu |
890ddd |
m_offy = toDouble(s);
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "lineProcessing") {
|
|
Toshihiro Shimizu |
890ddd |
m_lineProcessingMode = lpGrey;
|
|
Toshihiro Shimizu |
890ddd |
string s = is.getTagAttribute("sharpness");
|
|
Toshihiro Shimizu |
890ddd |
if (s != "" && isDouble(s))
|
|
Toshihiro Shimizu |
890ddd |
m_sharpness = toDouble(s);
|
|
Toshihiro Shimizu |
890ddd |
s = is.getTagAttribute("autoAdjust");
|
|
Toshihiro Shimizu |
890ddd |
if (s != "" && isDouble(s))
|
|
Toshihiro Shimizu |
890ddd |
m_autoAdjustMode = (CleanupTypes::AUTO_ADJ_MODE)toInt(s);
|
|
Toshihiro Shimizu |
890ddd |
s = is.getTagAttribute("mode");
|
|
Toshihiro Shimizu |
890ddd |
if (s != "" && s == "color")
|
|
Toshihiro Shimizu |
890ddd |
m_lineProcessingMode = lpColor;
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "despeckling") {
|
|
Toshihiro Shimizu |
890ddd |
string s = is.getTagAttribute("value");
|
|
Toshihiro Shimizu |
890ddd |
if (s != "" && isInt(s))
|
|
Toshihiro Shimizu |
890ddd |
m_despeckling = toInt(s);
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "aaValue") {
|
|
Toshihiro Shimizu |
890ddd |
string s = is.getTagAttribute("value");
|
|
Toshihiro Shimizu |
890ddd |
if (s != "" && isInt(s))
|
|
Toshihiro Shimizu |
890ddd |
m_aaValue = toInt(s);
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "noAntialias")
|
|
Toshihiro Shimizu |
890ddd |
m_noAntialias = true;
|
|
Toshihiro Shimizu |
890ddd |
else if (tagName == "MLAA")
|
|
Toshihiro Shimizu |
890ddd |
m_postAntialias = true;
|
|
Toshihiro Shimizu |
890ddd |
else if (tagName == "closestField") {
|
|
Toshihiro Shimizu |
890ddd |
string s = is.getTagAttribute("value");
|
|
Toshihiro Shimizu |
890ddd |
if (s != "" && isDouble(s))
|
|
Toshihiro Shimizu |
890ddd |
m_closestField = toDouble(s);
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "fdg") {
|
|
Toshihiro Shimizu |
890ddd |
string s = is.getTagAttribute("name");
|
|
Toshihiro Shimizu |
890ddd |
if (s != "")
|
|
Toshihiro Shimizu |
890ddd |
setFdgByName(s);
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "path") {
|
|
Toshihiro Shimizu |
890ddd |
is >> m_path;
|
|
Toshihiro Shimizu |
890ddd |
is.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
is.skipCurrentTag();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
CleanupParameters::LastSavedParameters.assign(this);
|
|
Toshihiro Shimizu |
890ddd |
if (globalParams)
|
|
Toshihiro Shimizu |
890ddd |
CleanupParameters::GlobalParameters.assign(this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const CleanupTypes::FDG_INFO &CleanupParameters::getFdgInfo()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_fdgInfo.m_name == "") {
|
|
Toshihiro Shimizu |
890ddd |
std::vector<string> names;</string>
|
|
Toshihiro Shimizu |
890ddd |
FdgManager::instance()->getFdgNames(names);
|
|
Toshihiro Shimizu |
890ddd |
if (names.size() > 1) {
|
|
Toshihiro Shimizu |
890ddd |
const CleanupTypes::FDG_INFO *info =
|
|
Toshihiro Shimizu |
890ddd |
FdgManager::instance()->getFdg(names[0]);
|
|
Toshihiro Shimizu |
890ddd |
if (info)
|
|
Toshihiro Shimizu |
890ddd |
m_fdgInfo = *info;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return m_fdgInfo;
|
|
Toshihiro Shimizu |
890ddd |
}
|