Skip to content

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

C

introducing stage-standarddpi

shun_iwasawad6df3f92619e
diff --git a/toonz/sources/common/tunit/tunit.cpp b/toonz/sources/common/tunit/tunit.cpp
index 2d3820232..fc2896cba 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; // Consider changing to 120 or 160
+ 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 af6f99e1d..c490aa8d0 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 3bf62b710..a71360684 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/toonz/camerasettingspopup.cpp b/toonz/sources/toonz/camerasettingspopup.cpp
index ec52cd05b..75da3d107 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 d9f6345ad..5a3bfc603 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();
diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp
index 0f0cfeb83..cf43fbda0 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());
diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cpp
index 826eb7f36..d039b34c3 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 3c9610a96..38b507291 100644
--- a/toonz/sources/toonzlib/stage.cpp
+++ b/toonz/sources/toonzlib/stage.cpp
@@ -69,8 +69,8 @@ typedef std::vector<Player> 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; // consider changing to 120 or 160
+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 97726621b..99d68c9ad 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 2da8e22a1..acfd5e81a 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 b02a5416f..b15818809 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);