diff --git a/toonz/sources/common/tunit/tunit.cpp b/toonz/sources/common/tunit/tunit.cpp index 2d38202..1d6063e 100644 --- a/toonz/sources/common/tunit/tunit.cpp +++ b/toonz/sources/common/tunit/tunit.cpp @@ -347,14 +347,15 @@ 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"), fxInch(L"in", new TSimpleUnitConverter(1 / stage_inch)), fxCm(L"cm", new TSimpleUnitConverter(2.54 / stage_inch)), fxMm(L"mm", new TSimpleUnitConverter(25.4 / stage_inch)), fxXfld(L"fld", new TSimpleUnitConverter(2 / stage_inch)), - fxPx(L"px", new TSimpleUnitConverter(1)); + fxPx(L"px", new TSimpleUnitConverter(stage_standardDpi / stage_inch)); fxInch.addExtension(L"inch"); fxInch.addExtension(L"\""); fxInch.addExtension(L"''"); diff --git a/toonz/sources/include/toonz/stage.h b/toonz/sources/include/toonz/stage.h index af6f99e..c490aa8 100644 --- a/toonz/sources/include/toonz/stage.h +++ b/toonz/sources/include/toonz/stage.h @@ -43,7 +43,7 @@ namespace Stage { //============================================================================= DVVAR extern const double inch; -DVVAR extern const double vectorDpi; +DVVAR extern const double standardDpi; class Visitor; struct VisitArgs; diff --git a/toonz/sources/include/toonz/tcamera.h b/toonz/sources/include/toonz/tcamera.h index 3bf62b7..a713606 100644 --- a/toonz/sources/include/toonz/tcamera.h +++ b/toonz/sources/include/toonz/tcamera.h @@ -42,6 +42,9 @@ Constructs TCamera with default value, size (12,9) and resolution (768,576). Constructs TCamera with default value, size (36, 20.25) and resolution (1920,1080). - 05/31/16 +Constructs TCamera with default value, size (16, 9) and resolution +(1920,1080). +- 08/16/16 */ TCamera(); 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/camerasettingspopup.cpp b/toonz/sources/toonz/camerasettingspopup.cpp index ec52cd0..75da3d1 100644 --- a/toonz/sources/toonz/camerasettingspopup.cpp +++ b/toonz/sources/toonz/camerasettingspopup.cpp @@ -244,7 +244,8 @@ void CameraSettingsPopup::updateFields() { TCamera *camera = cameraObject->getCamera(); if (Preferences::instance()->getPixelsOnly()) { TDimension res = camera->getRes(); - camera->setSize(TDimensionD(res.lx / Stage::inch, res.ly / Stage::inch)); + camera->setSize( + TDimensionD(res.lx / Stage::standardDpi, res.ly / Stage::standardDpi)); } if (camera) m_cameraSettingsWidget->setFields(camera); } diff --git a/toonz/sources/toonz/iocommand.cpp b/toonz/sources/toonz/iocommand.cpp index d9f6345..f1b35d0 100644 --- a/toonz/sources/toonz/iocommand.cpp +++ b/toonz/sources/toonz/iocommand.cpp @@ -1257,8 +1257,8 @@ bool IoCmd::saveSceneIfNeeded(QString msg) { void IoCmd::newScene() { RenderingSuspender suspender; TApp *app = TApp::instance(); - double cameraDpi = 53.33333; // used to be 64, consider changing to 120 or - // 160 + double cameraDpi = 120; // used to be 64 and 53.33333 + if (!saveSceneIfNeeded(QApplication::tr("New Scene"))) return; IconGenerator::instance()->clearRequests(); @@ -1861,6 +1861,35 @@ 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( + "This scene is incompatible with pixels only mode of the current " + "OpenToonz version.\nWhat would you like to do?"); + QString turnOffPixelAnswer = QObject::tr("Turn off pixels only mode"); + QString resizeSceneAnswer = + QObject::tr("Keep pixels only mode on and resize the scene"); + int ret = + DVGui::MsgBox(question, turnOffPixelAnswer, resizeSceneAnswer, 0); + if (ret == 0) { + } // do nothing + else if (ret == 1) { // Turn off pixels only mode + Preferences::instance()->setPixelsOnly(false); + app->getCurrentScene()->notifyPixelUnitSelected(false); + } else { // ret = 2 : Resize the scene + TDimensionD camSize = scene->getCurrentCamera()->getSize(); + TDimension camRes(camSize.lx * Stage::standardDpi, + camSize.ly * Stage::standardDpi); + scene->getCurrentCamera()->setRes(camRes); + 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 c76a3c9..f61fbc3 100644 --- a/toonz/sources/toonz/preferencespopup.cpp +++ b/toonz/sources/toonz/preferencespopup.cpp @@ -27,6 +27,7 @@ #include "toonz/tcamera.h" #include "toonz/levelproperties.h" #include "toonz/tonionskinmaskhandle.h" +#include "toonz/stage.h" // TnzCore includes #include "tsystem.h" @@ -217,22 +218,22 @@ Preferences::LevelFormat PreferencesPopup::FormatProperties::levelFormat() void PreferencesPopup::onPixelsOnlyChanged(int index) { bool enabled = index == Qt::Checked; if (enabled) { - m_pref->setDefLevelDpi(53.33333); + m_pref->setDefLevelDpi(Stage::standardDpi); m_pref->setPixelsOnly(true); TCamera *camera; camera = TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera(); TDimension camRes = camera->getRes(); TDimensionD camSize; - camSize.lx = camRes.lx / 53.33333; - camSize.ly = camRes.ly / 53.33333; + camSize.lx = camRes.lx / Stage::standardDpi; + camSize.ly = camRes.ly / Stage::standardDpi; camera->setSize(camSize); TDimension cleanupRes = CleanupSettingsModel::instance() ->getCurrentParameters() ->m_camera.getRes(); TDimensionD cleanupSize; - cleanupSize.lx = cleanupRes.lx / 53.33333; - cleanupSize.ly = cleanupRes.ly / 53.33333; + cleanupSize.lx = cleanupRes.lx / Stage::standardDpi; + cleanupSize.ly = cleanupRes.ly / Stage::standardDpi; CleanupSettingsModel::instance()->getCurrentParameters()->m_camera.setSize( cleanupSize); m_pref->storeOldUnits(); @@ -241,7 +242,7 @@ void PreferencesPopup::onPixelsOnlyChanged(int index) { m_unitOm->setDisabled(true); m_cameraUnitOm->setDisabled(true); m_defLevelDpi->setDisabled(true); - m_defLevelDpi->setValue(53.33333); + m_defLevelDpi->setValue(Stage::standardDpi); m_defLevelWidth->setMeasure("camera.lx"); m_defLevelHeight->setMeasure("camera.ly"); m_defLevelWidth->setValue(m_pref->getDefLevelWidth()); @@ -275,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); @@ -1844,6 +1854,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 e2cb9a7..7677d22 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/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cpp index 826eb7f..d039b34 100644 --- a/toonz/sources/toonz/sceneviewer.cpp +++ b/toonz/sources/toonz/sceneviewer.cpp @@ -1864,8 +1864,12 @@ void SceneViewer::zoomQt(bool forward, bool reset) { /*! a factor for getting pixel-based zoom ratio */ double SceneViewer::getDpiFactor() { + // When the current unit is "pixels", always use a standard dpi + if (Preferences::instance()->getPixelsOnly()) { + return Stage::inch / Stage::standardDpi; + } // When preview mode, use a camera DPI - if (isPreviewEnabled()) { + else if (isPreviewEnabled()) { return Stage::inch / TApp::instance() ->getCurrentScene() diff --git a/toonz/sources/toonzlib/stage.cpp b/toonz/sources/toonzlib/stage.cpp index 3c9610a..ad340da 100644 --- a/toonz/sources/toonzlib/stage.cpp +++ b/toonz/sources/toonzlib/stage.cpp @@ -69,8 +69,8 @@ typedef std::vector PlayerSet; thickness of images .pli. */ -const double Stage::inch = 53.33333; // consider changing to 120 or 160 -const double Stage::vectorDpi = 53.3333; +const double Stage::inch = 53.33333; +const double Stage::standardDpi = 120; namespace { void updateOnionSkinSize(const PlayerSet &players) { diff --git a/toonz/sources/toonzlib/tcamera.cpp b/toonz/sources/toonzlib/tcamera.cpp index 9772662..99d68c9 100644 --- a/toonz/sources/toonzlib/tcamera.cpp +++ b/toonz/sources/toonzlib/tcamera.cpp @@ -10,7 +10,8 @@ TCamera::TCamera() //: m_size(12, 9), m_res(768, 576), m_xPrevalence(true) - : m_size(36, 20.25), + //: m_size(36, 20.25), + : m_size(16, 9), m_res(1920, 1080), m_xPrevalence(true) {} diff --git a/toonz/sources/toonzqt/camerasettingswidget.cpp b/toonz/sources/toonzqt/camerasettingswidget.cpp index 2da8e22..acfd5e8 100644 --- a/toonz/sources/toonzqt/camerasettingswidget.cpp +++ b/toonz/sources/toonzqt/camerasettingswidget.cpp @@ -759,8 +759,8 @@ void CameraSettingsWidget::onYResChanged() { void CameraSettingsWidget::onXDpiChanged() { if (Preferences::instance()->getPixelsOnly()) { - m_xDpiFld->setValue(Stage::inch); - m_yDpiFld->setValue(Stage::inch); + m_xDpiFld->setValue(Stage::standardDpi); + m_yDpiFld->setValue(Stage::standardDpi); } else if (m_fspChk->isChecked()) m_yDpiFld->setValue(m_xDpiFld->getValue()); @@ -781,8 +781,8 @@ void CameraSettingsWidget::onXDpiChanged() { void CameraSettingsWidget::onYDpiChanged() { if (Preferences::instance()->getPixelsOnly()) { - m_xDpiFld->setValue(Stage::inch); - m_yDpiFld->setValue(Stage::inch); + m_xDpiFld->setValue(Stage::standardDpi); + m_yDpiFld->setValue(Stage::standardDpi); } else if (m_fspChk->isChecked()) m_xDpiFld->setValue(m_yDpiFld->getValue()); @@ -850,8 +850,8 @@ void CameraSettingsWidget::onPresetSelected(const QString &str) { } if (Preferences::instance()->getPixelsOnly()) { - m_lxFld->setValue(xres / Stage::inch); - m_lyFld->setValue(yres / Stage::inch); + m_lxFld->setValue(xres / Stage::standardDpi); + m_lyFld->setValue(yres / Stage::standardDpi); } if (m_forCleanup && m_offsX && m_offsY && !xoffset.isEmpty() && diff --git a/toonz/sources/toonzqt/cleanupcamerasettingswidget.cpp b/toonz/sources/toonzqt/cleanupcamerasettingswidget.cpp index b02a541..b158188 100644 --- a/toonz/sources/toonzqt/cleanupcamerasettingswidget.cpp +++ b/toonz/sources/toonzqt/cleanupcamerasettingswidget.cpp @@ -95,7 +95,7 @@ void CleanupCameraSettingsWidget::setFields( if (Preferences::instance()->getPixelsOnly()) { TDimension res = cleanupParameters->m_camera.getRes(); cleanupParameters->m_camera.setSize( - TDimensionD(res.lx / Stage::inch, res.ly / Stage::inch)); + TDimensionD(res.lx / Stage::standardDpi, res.ly / Stage::standardDpi)); } m_cameraWidget->setFields(&cleanupParameters->m_camera); m_offsX->setValue(cleanupParameters->m_offx); diff --git a/toonz/sources/toonzqt/dvdialog.cpp b/toonz/sources/toonzqt/dvdialog.cpp index 3692f7e..281586e 100644 --- a/toonz/sources/toonzqt/dvdialog.cpp +++ b/toonz/sources/toonzqt/dvdialog.cpp @@ -31,7 +31,7 @@ using namespace DVGui; -QString DialogTitle = QObject::tr("OpenToonz 1.0"); +QString DialogTitle = QObject::tr("OpenToonz 1.1"); //============================================================================= namespace {