OpenToonz - An open-source full-featured 2D animation creation software
C
add dpi compatibility check and remove comment
shun_iwasawabb0d83547aa9
diff --git a/toonz/sources/common/tunit/tunit.cpp b/toonz/sources/common/tunit/tunit.cppindex fc2896cba..1d6063ea9 100644--- a/toonz/sources/common/tunit/tunit.cpp+++ b/toonz/sources/common/tunit/tunit.cpp@@ -347,7 +347,7 @@ TMeasureManager::TMeasureManager() {m->add(cameraYFld.clone());add(m);- const double stage_inch = 53.33333; // Consider changing to 120 or 160+ const double stage_inch = 53.33333;const double stage_standardDpi = 120;TUnit fxLength(L"fxLength"),diff --git a/toonz/sources/include/toonz/tscenehandle.h b/toonz/sources/include/toonz/tscenehandle.hindex fab6259fe..bc8ded561 100644--- a/toonz/sources/include/toonz/tscenehandle.h+++ b/toonz/sources/include/toonz/tscenehandle.h@@ -54,6 +54,8 @@ public:void notifyPreferenceChanged() { emit preferenceChanged(); }+ void notifyPixelUnitSelected(bool on) { emit pixelUnitSelected(on); }+void setDirtyFlag(bool dirtyFlag) {if (m_dirtyFlag == dirtyFlag) return;m_dirtyFlag = dirtyFlag;@@ -75,6 +77,7 @@ signals:void castFolderAdded(const TFilePath &path);void nameSceneChanged();void preferenceChanged();+ void pixelUnitSelected(bool on);};#endif // TSCENEHANDLE_Hdiff --git a/toonz/sources/toonz/iocommand.cpp b/toonz/sources/toonz/iocommand.cppindex 5a3bfc603..bb7e6d7a9 100644--- a/toonz/sources/toonz/iocommand.cpp+++ b/toonz/sources/toonz/iocommand.cpp@@ -1861,6 +1861,32 @@ bool IoCmd::loadScene(const TFilePath &path, bool updateRecentFile,QAction *act = CommandManager::instance()->getAction(MI_RevertScene);if (act) act->setEnabled(exist);+ // check if the output dpi is incompatible with pixels only mode+ if (Preferences::instance()->getPixelsOnly()) {+ TPointD dpi = scene->getCurrentCamera()->getDpi();+ if (!areAlmostEqual(dpi.x, Stage::standardDpi) ||+ !areAlmostEqual(dpi.y, Stage::standardDpi)) {+ QString question = QObject::tr(+ "The camera dpi is incompatible with pixels only mode. What would "+ "you like to do?");+ QString turnOffPixelAnswer = QObject::tr("Turn off pixels only mode");+ QString changeDpiAnswer = QObject::tr("Change the camera dpi");+ int ret = DVGui::MsgBox(question, turnOffPixelAnswer, changeDpiAnswer, 0);+ if (ret == 0) {+ } // do nothing+ else if (ret == 1) { // Turn off pixels only mode+ app->getCurrentScene()->notifyPixelUnitSelected(false);+ } else { // ret = 2 : Change the camera dpi+ TDimension camRes = scene->getCurrentCamera()->getRes();+ TDimensionD camSize(camRes.lx / Stage::standardDpi,+ camRes.ly / Stage::standardDpi);+ scene->getCurrentCamera()->setSize(camSize);+ app->getCurrentScene()->setDirtyFlag(true);+ app->getCurrentXsheet()->notifyXsheetChanged();+ }+ }+ }+printf("%s:%s loadScene() completed :\n", __FILE__, __FUNCTION__);return true;}diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cppindex cf43fbda0..c9c96c95b 100644--- a/toonz/sources/toonz/preferencespopup.cpp+++ b/toonz/sources/toonz/preferencespopup.cpp@@ -276,6 +276,15 @@ void PreferencesPopup::onPixelsOnlyChanged(int index) {}}+//-----------------------------------------------------------------------------++void PreferencesPopup::onPixelUnitExternallySelected(bool on) {+ // call slot function onPixelsOnlyChanged() accordingly+ m_pixelsOnlyCB->setCheckState((on) ? Qt::Checked : Qt::Unchecked);+}++//-----------------------------------------------------------------------------+void PreferencesPopup::onUnitChanged(int index) {if (index == 4 && m_pixelsOnlyCB->isChecked() == false) {m_pixelsOnlyCB->setCheckState(Qt::Checked);@@ -1834,6 +1843,11 @@ PreferencesPopup::PreferencesPopup()SLOT(onStyleSheetTypeChanged(int)));ret = ret && connect(m_pixelsOnlyCB, SIGNAL(stateChanged(int)),SLOT(onPixelsOnlyChanged(int)));+ // pixels unit may deactivated externally on loading scene (see+ // IoCmd::loadScene())+ ret = ret && connect(TApp::instance()->getCurrentScene(),+ SIGNAL(pixelUnitSelected(bool)), this,+ SLOT(onPixelUnitExternallySelected(bool)));ret = ret && connect(m_unitOm, SIGNAL(currentIndexChanged(int)),SLOT(onUnitChanged(int)));ret = ret && connect(m_cameraUnitOm, SIGNAL(currentIndexChanged(int)),diff --git a/toonz/sources/toonz/preferencespopup.h b/toonz/sources/toonz/preferencespopup.hindex 8e8b640ec..db994eb78 100644--- a/toonz/sources/toonz/preferencespopup.h+++ b/toonz/sources/toonz/preferencespopup.h@@ -79,6 +79,7 @@ private:private slots:void onPixelsOnlyChanged(int index);+ void onPixelUnitExternallySelected(bool on);void onUnitChanged(int index);void onCameraUnitChanged(int index);void onRoomChoiceChanged(int index);diff --git a/toonz/sources/toonzlib/stage.cpp b/toonz/sources/toonzlib/stage.cppindex 38b507291..ad340da4b 100644--- a/toonz/sources/toonzlib/stage.cpp+++ b/toonz/sources/toonzlib/stage.cpp@@ -69,7 +69,7 @@ typedef std::vector<Player> PlayerSet;thickness ofimages .pli.*/-const double Stage::inch = 53.33333; // consider changing to 120 or 160+const double Stage::inch = 53.33333;const double Stage::standardDpi = 120;namespace {