Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

skip unnecessary icon invalidation

shun-iwasawa6fe42015eecf
diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cpp
index b84206164..66e5b90fe 100644
--- a/toonz/sources/toonz/sceneviewer.cpp
+++ b/toonz/sources/toonz/sceneviewer.cpp
@@ -297,9 +297,9 @@ void invalidateIcons() {
s.m_paintIndex = mask & ToonzCheck::ePaint ? tc->getColorIndex() : -1;
IconGenerator::instance()->setSettings(s);
- // Force icons to refresh
+ // Force icons to refresh for Toonz Vector levels
TXshLevel *sl = TApp::instance()->getCurrentLevel()->getLevel();
- if (sl) {
+ if (sl && sl->getType() == PLI_XSHLEVEL) {
std::vector<TFrameId> fids;
sl->getFids(fids);
@@ -2026,7 +2026,7 @@ double SceneViewer::projectToZ(const TPointD &delta) {
GLint viewport[4];
double modelview[16], projection[16];
glGetIntegerv(GL_VIEWPORT, viewport);
- for (int i = 0; i < 16; i++)
+ for (int i = 0; i < 16; i++)
projection[i] = (double)m_projectionMatrix.constData()[i];
glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
@@ -2188,8 +2188,9 @@ void SceneViewer::zoomQt(bool forward, bool reset) {
if (reset || ((m_zoomScale3D < 500 || !forward) &&
(m_zoomScale3D > 0.01 || forward))) {
double oldZoomScale = m_zoomScale3D;
- m_zoomScale3D = reset ? 1 : ImageUtils::getQuantizedZoomFactor(
- m_zoomScale3D, forward);
+ m_zoomScale3D =
+ reset ? 1
+ : ImageUtils::getQuantizedZoomFactor(m_zoomScale3D, forward);
m_pan3D = -(m_zoomScale3D / oldZoomScale) * -m_pan3D;
}
@@ -2210,17 +2211,18 @@ void SceneViewer::zoomQt(bool forward, bool reset) {
int i;
for (i = 0; i < 2; i++) {
- TAffine &viewAff = m_viewAff[i];
+ TAffine &viewAff = m_viewAff[i];
if (m_isFlippedX) viewAff = viewAff * TScale(-1, 1);
if (m_isFlippedX) viewAff = viewAff * TScale(1, -1);
- double scale2 = std::abs(viewAff.det());
+ double scale2 = std::abs(viewAff.det());
if (m_isFlippedX) viewAff = viewAff * TScale(-1, 1);
if (m_isFlippedX) viewAff = viewAff * TScale(1, -1);
if (reset || ((scale2 < 100000 || !forward) &&
(scale2 > 0.001 * 0.05 || forward))) {
double oldZoomScale = sqrt(scale2) * dpiFactor;
- double zoomScale = reset ? 1 : ImageUtils::getQuantizedZoomFactor(
- oldZoomScale, forward);
+ double zoomScale =
+ reset ? 1
+ : ImageUtils::getQuantizedZoomFactor(oldZoomScale, forward);
// threshold value -0.001 is intended to absorb the error of calculation
if ((oldZoomScale - zoomScaleFittingWithScreen) *
@@ -2523,9 +2525,9 @@ void SceneViewer::fitToCamera() {
TPointD P11 = cameraAff * cameraRect.getP11();
TPointD p0 = TPointD(std::min({P00.x, P01.x, P10.x, P11.x}),
std::min({P00.y, P01.y, P10.y, P11.y}));
- TPointD p1 = TPointD(std::max({P00.x, P01.x, P10.x, P11.x}),
+ TPointD p1 = TPointD(std::max({P00.x, P01.x, P10.x, P11.x}),
std::max({P00.y, P01.y, P10.y, P11.y}));
- cameraRect = TRectD(p0.x, p0.y, p1.x, p1.y);
+ cameraRect = TRectD(p0.x, p0.y, p1.x, p1.y);
// Pan
if (!is3DView()) {
@@ -2568,9 +2570,9 @@ void SceneViewer::fitToCameraOutline() {
TPointD P11 = cameraAff * cameraRect.getP11();
TPointD p0 = TPointD(std::min({P00.x, P01.x, P10.x, P11.x}),
std::min({P00.y, P01.y, P10.y, P11.y}));
- TPointD p1 = TPointD(std::max({P00.x, P01.x, P10.x, P11.x}),
+ TPointD p1 = TPointD(std::max({P00.x, P01.x, P10.x, P11.x}),
std::max({P00.y, P01.y, P10.y, P11.y}));
- cameraRect = TRectD(p0.x, p0.y, p1.x, p1.y);
+ cameraRect = TRectD(p0.x, p0.y, p1.x, p1.y);
// Pan
if (!is3DView()) {
@@ -2620,8 +2622,8 @@ void SceneViewer::resetZoom() {
TPointD realCenter(m_viewAff[m_viewMode].a13, m_viewAff[m_viewMode].a23);
TAffine aff =
getNormalZoomScale() * TRotation(realCenter, m_rotationAngle[m_viewMode]);
- aff.a13 = realCenter.x;
- aff.a23 = realCenter.y;
+ aff.a13 = realCenter.x;
+ aff.a23 = realCenter.y;
if (m_isFlippedX) aff = aff * TScale(-1, 1);
if (m_isFlippedY) aff = aff * TScale(1, -1);
setViewMatrix(aff, m_viewMode);
@@ -2678,16 +2680,17 @@ void SceneViewer::setActualPixelSize() {
} else
dpi = sl->getDpi(fid);
- const double inch = Stage::inch;
- TAffine tempAff = getNormalZoomScale();
- if (m_isFlippedX) tempAff = tempAff * TScale(-1, 1);
- if (m_isFlippedY) tempAff = tempAff * TScale(1, -1);
- TPointD tempScale = dpi;
+ const double inch = Stage::inch;
+ TAffine tempAff = getNormalZoomScale();
+ if (m_isFlippedX) tempAff = tempAff * TScale(-1, 1);
+ if (m_isFlippedY) tempAff = tempAff * TScale(1, -1);
+ TPointD tempScale = dpi;
if (m_isFlippedX) tempScale.x = -tempScale.x;
if (m_isFlippedY) tempScale.y = -tempScale.y;
for (int i = 0; i < m_viewAff.size(); ++i)
- setViewMatrix(dpi == TPointD(0, 0) ? tempAff : TScale(tempScale.x / inch,
- tempScale.y / inch),
+ setViewMatrix(dpi == TPointD(0, 0)
+ ? tempAff
+ : TScale(tempScale.x / inch, tempScale.y / inch),
i);
m_pos = QPoint(0, 0);
@@ -2970,7 +2973,7 @@ void drawSpline(const TAffine &viewMatrix, const TRect &clipRect, bool camera3d,
TStageObject *pegbar =
objId != TStageObjectId::NoneId ? xsh->getStageObject(objId) : 0;
- const TStroke *stroke = 0;
+ const TStroke *stroke = 0;
if (pegbar && pegbar->getSpline()) stroke = pegbar->getSpline()->getStroke();
if (!stroke) return;
diff --git a/toonz/sources/toonz/tapp.cpp b/toonz/sources/toonz/tapp.cpp
index f5b0bdec8..d72a14a52 100644
--- a/toonz/sources/toonz/tapp.cpp
+++ b/toonz/sources/toonz/tapp.cpp
@@ -593,6 +593,10 @@ void TApp::onPaletteChanged() { m_currentScene->setDirtyFlag(true); }
//-----------------------------------------------------------------------------
void TApp::onLevelColorStyleSwitched() {
+ TXshLevel *sl = m_currentLevel->getLevel();
+ if (!sl || (sl->getType() != TZP_XSHLEVEL && sl->getType() != PLI_XSHLEVEL))
+ return;
+
TPaletteHandle *ph = m_paletteController->getCurrentLevelPalette();
assert(ph);
@@ -610,14 +614,12 @@ void TApp::onLevelColorStyleSwitched() {
IconGenerator::instance()->setSettings(s);
- TXshLevel *sl = m_currentLevel->getLevel();
- if (!sl) return;
-
- std::vector<TFrameId> fids;
- sl->getFids(fids);
-
- for (int i = 0; i < (int)fids.size(); i++)
- IconGenerator::instance()->invalidate(sl, fids[i]);
+ if (sl->getType() == PLI_XSHLEVEL) {
+ std::vector<TFrameId> fids;
+ sl->getFids(fids);
+ for (int i = 0; i < (int)fids.size(); i++)
+ IconGenerator::instance()->invalidate(sl, fids[i]);
+ }
m_currentLevel->notifyLevelViewChange();
}
diff --git a/toonz/sources/toonzlib/tpalettehandle.cpp b/toonz/sources/toonzlib/tpalettehandle.cpp
index a653b5b6a..001350758 100644
--- a/toonz/sources/toonzlib/tpalettehandle.cpp
+++ b/toonz/sources/toonzlib/tpalettehandle.cpp
@@ -149,6 +149,8 @@ void TPaletteHandle::setPalette(TPalette *palette, int styleIndex) {
m_styleParamIndex = 0;
emit paletteSwitched();
+ // to let ToonzCheck to update the current index
+ emit broadcastColorStyleSwitched();
}
}
diff --git a/toonz/sources/toonzlib/txshsimplelevel.cpp b/toonz/sources/toonzlib/txshsimplelevel.cpp
index dc2351442..dee522143 100644
--- a/toonz/sources/toonzlib/txshsimplelevel.cpp
+++ b/toonz/sources/toonzlib/txshsimplelevel.cpp
@@ -1600,6 +1600,7 @@ void TXshSimpleLevel::saveSimpleLevel(const TFilePath &decodedFp,
if (TSystem::doesExistFileOrLevel(decodedFp)) {
TLevelReaderP lr(decodedFp);
+ lr->doReadPalette(false);
const TImageInfo *imageInfo = m_frames.empty()
? lr->getImageInfo()
: lr->getImageInfo(*(m_frames.begin()));