From b8b432234dd458d91eb872c7f3bc224f8564a782 Mon Sep 17 00:00:00 2001 From: shun-iwasawa Date: Fri, 9 Apr 2021 15:32:04 +0900 Subject: [PATCH 1/2] fix shift and trace scaling --- toonz/sources/tnztools/shifttracetool.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/toonz/sources/tnztools/shifttracetool.cpp b/toonz/sources/tnztools/shifttracetool.cpp index b295c7e7..b641a3f0 100644 --- a/toonz/sources/tnztools/shifttracetool.cpp +++ b/toonz/sources/tnztools/shifttracetool.cpp @@ -529,15 +529,17 @@ void ShiftTraceTool::leftButtonDrag(const TPointD &pos, const TMouseEvent &e) { m_oldPos = pos; m_aff[m_ghostIndex] = TTranslation(delta) * m_aff[m_ghostIndex]; } else if (m_gadget == ScaleGadget) { - TAffine aff = getGhostAff(); - TPointD c = aff * m_center[m_ghostIndex]; - TPointD a = m_oldPos - c; - TPointD b = pos - c; + TAffine aff = getGhostAff(); + TPointD c = m_center[m_ghostIndex]; + TPointD a = aff.inv() * m_oldPos - c; + TPointD b = aff.inv() * pos - c; + TPointD imgC = aff * m_center[m_ghostIndex]; + if (e.isShiftPressed()) - m_aff[m_ghostIndex] = m_oldAff * TScale(b.x / a.x, b.y / a.y); + m_aff[m_ghostIndex] = TScale(imgC, b.x / a.x, b.y / a.y) * m_oldAff; else { double scale = std::max(b.x / a.x, b.y / a.y); - m_aff[m_ghostIndex] = m_oldAff * TScale(scale, scale); + m_aff[m_ghostIndex] = TScale(imgC, scale) * m_oldAff; } } From d81107518d2f8231da1c288243d432cd9e691144 Mon Sep 17 00:00:00 2001 From: shun-iwasawa Date: Wed, 14 Apr 2021 14:15:52 +0900 Subject: [PATCH 2/2] fix psd loading --- toonz/sources/include/toonz/toonzscene.h | 8 ++++++++ toonz/sources/toonzlib/toonzscene.cpp | 14 +++++++++++--- toonz/sources/toonzlib/txshsimplelevel.cpp | 6 ++++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/toonz/sources/include/toonz/toonzscene.h b/toonz/sources/include/toonz/toonzscene.h index 8bedae4c..10c3897a 100644 --- a/toonz/sources/include/toonz/toonzscene.h +++ b/toonz/sources/include/toonz/toonzscene.h @@ -259,6 +259,9 @@ If \b scene is in +scenes/name.tnz return name, // if the path is codable with $scenefolder alias, replace it and return true bool codeFilePathWithSceneFolder(TFilePath &path) const; + bool isLoading() { return m_isLoading; } + void setIsLoading(bool isLoading) { m_isLoading = isLoading; } + private: TFilePath m_scenePath; //!< Full path to the scene file (.tnz). @@ -273,6 +276,11 @@ private: // currently it is not match with OT version. // TODO: Revise VersionNumber with OT version + bool m_isLoading; // Set to true while loading the scene. Currently this flag + // is used when loading PSD levels, for defining whether to + // convert a layerId in the path to the layer name. See + // TXshSimpleLevel::load(). + private: // noncopyable ToonzScene(const ToonzScene &); diff --git a/toonz/sources/toonzlib/toonzscene.cpp b/toonz/sources/toonzlib/toonzscene.cpp index d9ccae2a..6de09827 100644 --- a/toonz/sources/toonzlib/toonzscene.cpp +++ b/toonz/sources/toonzlib/toonzscene.cpp @@ -276,7 +276,8 @@ static void deleteAllUntitledScenes() { //============================================================================= // ToonzScene -ToonzScene::ToonzScene() : m_contentHistory(0), m_isUntitled(true) { +ToonzScene::ToonzScene() + : m_contentHistory(0), m_isUntitled(true), m_isLoading(false) { m_childStack = new ChildStack(this); m_properties = new TSceneProperties(); m_levelSet = new TLevelSet(); @@ -348,8 +349,15 @@ bool ToonzScene::isUntitled() const { //----------------------------------------------------------------------------- void ToonzScene::load(const TFilePath &path, bool withProgressDialog) { - loadNoResources(path); - loadResources(withProgressDialog); + setIsLoading(true); + try { + loadNoResources(path); + loadResources(withProgressDialog); + } catch (...) { + setIsLoading(false); + throw; + } + setIsLoading(false); } //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonzlib/txshsimplelevel.cpp b/toonz/sources/toonzlib/txshsimplelevel.cpp index 0a56cac1..4370021d 100644 --- a/toonz/sources/toonzlib/txshsimplelevel.cpp +++ b/toonz/sources/toonzlib/txshsimplelevel.cpp @@ -1177,8 +1177,10 @@ void TXshSimpleLevel::load() { } else { // Not a scan + cleanup level - if (m_path.getType() == "psd" && - this->getScene()->getVersionNumber().first < 71) + // Loading PSD files via load level command needs to convert layerID in the + // file path to layer name here. The conversion is not needed on loading + // scene as the file path loaded from the scene file is already converted. + if (m_path.getType() == "psd" && !this->getScene()->isLoading()) m_path = getLevelPathAndSetNameWithPsdLevelName(this); TFilePath path = getScene()->decodeFilePath(m_path);