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