From bb0d83547aa99fb4ce3e2240b9e6def2c477a6af Mon Sep 17 00:00:00 2001 From: shun_iwasawa Date: Aug 18 2016 08:27:10 +0000 Subject: add dpi compatibility check and remove comment --- diff --git a/toonz/sources/common/tunit/tunit.cpp b/toonz/sources/common/tunit/tunit.cpp index fc2896c..1d6063e 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.h index fab6259..bc8ded5 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_H diff --git a/toonz/sources/toonz/iocommand.cpp b/toonz/sources/toonz/iocommand.cpp index 5a3bfc6..bb7e6d7 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.cpp index cf43fbd..c9c96c9 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.h index 8e8b640..db994eb 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.cpp index 38b5072..ad340da 100644 --- a/toonz/sources/toonzlib/stage.cpp +++ b/toonz/sources/toonzlib/stage.cpp @@ -69,7 +69,7 @@ typedef std::vector PlayerSet; thickness of images .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 {